123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- #!/usr/bin/env python3
- import json
- import os
- import sys
- import random
- build_dirs = [ "./../build/bin/" , "./../build/py/" ]
- targets = [ "tests-128", "tests-256", "tests-dbg-128", "tests-dbg-256", "examples-256", "xrnlib-128-cli", "xrnlib-cli", "xrnlib-256-cli", "_xrnlib256.so" ]
- target_path = ""
- target_name = ""
- for build_dir in build_dirs :
- for target in targets :
- if ( os.path.exists(build_dir+target) ):
- target_path = build_dir+target
- target_name = target
- break
- clean_cache_str = " rm -rf ../cache/* ; "
- if ( target_name == "xrnlib-cli" ) :
- if ( len(sys.argv) == 2 ) :
- cmd="cd ./backend/parser_tests/; bash ./run_parser_tests.sh " + sys.argv[1]
- os.system(cmd);
- else :
- cmd="cd ./backend/parser_tests/; bash ./run_parser_tests.sh "
- os.system(cmd);
- if (( target_name == "tests-128" ) or ( target_name == "tests-256" )):
- cmd = clean_cache_str + " cd ../cache ; cp -r ../archives/resources/code_examples/* . ; " + target_path
- os.system(cmd);
- if (( target_name == "tests-dbg-128" ) or ( target_name == "tests-dbg-256" )):
- cmd = clean_cache_str + " cd ../cache ; cp -r ../archives/resources/code_examples/* . ; valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes " + target_path + " 2>../build/reports/valgrind_stderr.rep >../build/reports/valgrind_stdout.rep "
- print(cmd)
- os.system(cmd);
- if ( target_name == "examples-256" ):
- if ( len(sys.argv) == 2 ) :
- if ( sys.argv[1] == "all" ):
- for i in range ( 35 ) :
- print("running "+str(i)+"/35")
- cmd = clean_cache_str + " cd ../cache ; cp -r ../archives/resources/code_examples/* . ; " + target_path + " " + str(i)
- os.system(cmd);
- else :
- cmd = clean_cache_str + " cd ../cache ; cp -r ../archives/resources/code_examples/* . ; " + target_path + " " + sys.argv[1]
- os.system(cmd);
- else :
- cmd = clean_cache_str + " cd ../cache ; cp -r ../archives/resources/code_examples/* . ; " + target_path
- os.system(cmd);
- if ( target_name == "_xrnlib256.so" ):
- all = 0
- if ( len(sys.argv) == 2 ) :
- if ( sys.argv[1] == "all" ):
- all = 1
- argvint = 0
- else :
- argvint = int(sys.argv[1])
- if (( len(sys.argv) != 2 ) or ( argvint < 0 ) or ( argvint >= 38 )):
- print( "implemented Python examples:" )
- print( "0) generate_xrn_matrix_one_third.py" )
- print( "1) generate_xrn_matrix_all_rnd.py" )
- print( "2) generate_keys_with_wrapper_functions.py" )
- print( "3) check_xrn_matrix.py" )
- print( "4) split_join_encryption_wrapper.py" )
- print( "5) split_join_encryption_bytes_wrapper.py" )
- print( "6) encrypt_symmetric_wrapper.py" )
- print( "7) encrypt_symmetric_bytes_wrapper.py" )
- print( "8) encrypt_asymmetric_wrapper.py" )
- print( "9) encrypt_asymmetric_bytes_wrapper.py" )
- print( "10) hash_bytes_wrapper.py" )
- print( "11) hash_file_wrapper.py" )
- print( "12) symmetric_signature_file_wrapper.py" )
- print( "13) symmetric_signature_bytes_wrapper.py" )
- print( "14) asymmetric_signature_file_wrapper.py" )
- print( "15) asymmetric_signature_bytes_wrapper.py" )
- print( "16) pseudo_random_number_generator_wrapper.py" )
- print( "17) ring_signature_file_wrapper.py" )
- print( "18) ring_signature_bytes_wrapper.py" )
- print( "19) monomial_key_exchange.py" )
- print( "20) certificate_symmetric.py" )
- print( "21) certificate_asymmetric.py" )
- print( "22) zero_knowledge_proof_binomial_key.py" )
- print( "23) zero_knowledge_proof_signature.py" )
- print( "24) zero_knowledge_proof_signature_bytes.py" )
- print( "25) zero_knowledge_proof_certificate.py" )
- print( "26) permute_xrn_matrix_compressed_rnd.py" )
- print( "27) permute_xrn_matrix_compressed_deterministic.py" )
- print( "28) permute_xrn_matrix_compressed_key.py" )
- print( "29) encoding_decoding_file_wrapper.py" )
- print( "30) encoding_decoding_bytes_wrapper.py" )
- print( "31) polyvalent_key_exchange.py" )
- print( "32) checksum_dump_file_wrapper.py" )
- print( "33) checksum_dump_bytes_wrapper.py" )
- print( "34) create_blocks_from_file.py" )
- print( "35) create_blocks_from_bytes.py" )
- print( "36) steganography_block_file.py" )
- print( "37) steganography_block_bytes.py" )
- exit(0)
- ordered_script_list = [ "generate_xrn_matrix_one_third.py",
- "generate_xrn_matrix_all_rnd.py",
- "generate_keys_with_wrapper_functions.py",
- "check_xrn_matrix.py",
- "split_join_encryption_wrapper.py",
- "split_join_encryption_bytes_wrapper.py",
- "encrypt_symmetric_wrapper.py",
- "encrypt_symmetric_bytes_wrapper.py",
- "encrypt_asymmetric_wrapper.py",
- "encrypt_asymmetric_bytes_wrapper.py",
- "hash_bytes_wrapper.py",
- "hash_file_wrapper.py",
- "symmetric_signature_file_wrapper.py",
- "symmetric_signature_bytes_wrapper.py",
- "asymmetric_signature_file_wrapper.py",
- "asymmetric_signature_bytes_wrapper.py",
- "pseudo_random_number_generator_wrapper.py",
- "ring_signature_file_wrapper.py",
- "ring_signature_bytes_wrapper.py",
- "monomial_key_exchange.py",
- "certificate_symmetric.py",
- "certificate_asymmetric.py",
- "zero_knowledge_proof_binomial_key.py",
- "zero_knowledge_proof_signature.py",
- "zero_knowledge_proof_signature_bytes.py",
- "zero_knowledge_proof_certificate.py",
- "permute_xrn_matrix_compressed_rnd.py",
- "permute_xrn_matrix_compressed_deterministic.py",
- "permute_xrn_matrix_compressed_key.py",
- "encoding_decoding_file_wrapper.py",
- "encoding_decoding_bytes_wrapper.py",
- "polyvalent_key_exchange.py",
- "checksum_dump_file_wrapper.py",
- "checksum_dump_bytes_wrapper.py",
- "create_blocks_from_file.py",
- "create_blocks_from_bytes.py",
- "steganography_block_file.py",
- "steganography_block_bytes.py"
- ]
- if ( all == 0 ) :
- pyscript = ordered_script_list[ argvint ]
- print("\nrunning " + pyscript + "\n" )
- cmd = clean_cache_str + " cp ./../build/py/_xrnlib256.so ../cache ; cp ./../build/py/xrnlib256.py ../cache ; "
- cmd = cmd + " cd ../cache ; cp -r ../archives/resources/code_examples/* . ; "
- cmd = cmd + " cp ../code/app/examples/py/" + pyscript + " . ; "
- cmd = cmd + " python3 " + pyscript + " ;"
- os.system(cmd);
- else :
- for i in range (len(ordered_script_list)):
- print("running "+str(i)+"/"+ str(len(ordered_script_list)))
- pyscript = ordered_script_list[ i ]
- print("\nrunning " + pyscript + "\n" )
- cmd = clean_cache_str + " cp ./../build/py/_xrnlib256.so ../cache ; cp ./../build/py/xrnlib256.py ../cache ; "
- cmd = cmd + " cd ../cache ; cp -r ../archives/resources/code_examples/* . ; "
- cmd = cmd + " cp ../code/app/examples/py/" + pyscript + " . ; "
- cmd = cmd + " python3 " + pyscript + " ;"
- print("cmd: "+cmd)
- os.system(cmd);
-
|