run.py 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #!/usr/bin/env python3
  2. import json
  3. import os
  4. import sys
  5. import random
  6. build_dirs = [ "./../build/bin/" , "./../build/py/" ]
  7. targets = [ "tests-128", "tests-256", "tests-dbg-128", "tests-dbg-256", "examples-256", "xrnlib-128-cli", "xrnlib-cli", "xrnlib-256-cli", "_xrnlib256.so" ]
  8. target_path = ""
  9. target_name = ""
  10. for build_dir in build_dirs :
  11. for target in targets :
  12. if ( os.path.exists(build_dir+target) ):
  13. target_path = build_dir+target
  14. target_name = target
  15. break
  16. clean_cache_str = " rm -rf ../cache/* ; "
  17. if ( target_name == "xrnlib-cli" ) :
  18. if ( len(sys.argv) == 2 ) :
  19. cmd="cd ./backend/parser_tests/; bash ./run_parser_tests.sh " + sys.argv[1]
  20. os.system(cmd);
  21. else :
  22. cmd="cd ./backend/parser_tests/; bash ./run_parser_tests.sh "
  23. os.system(cmd);
  24. if (( target_name == "tests-128" ) or ( target_name == "tests-256" )):
  25. cmd = clean_cache_str + " cd ../cache ; cp -r ../archives/resources/code_examples/* . ; " + target_path
  26. os.system(cmd);
  27. if (( target_name == "tests-dbg-128" ) or ( target_name == "tests-dbg-256" )):
  28. 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 "
  29. print(cmd)
  30. os.system(cmd);
  31. if ( target_name == "examples-256" ):
  32. if ( len(sys.argv) == 2 ) :
  33. if ( sys.argv[1] == "all" ):
  34. for i in range ( 35 ) :
  35. print("running "+str(i)+"/35")
  36. cmd = clean_cache_str + " cd ../cache ; cp -r ../archives/resources/code_examples/* . ; " + target_path + " " + str(i)
  37. os.system(cmd);
  38. else :
  39. cmd = clean_cache_str + " cd ../cache ; cp -r ../archives/resources/code_examples/* . ; " + target_path + " " + sys.argv[1]
  40. os.system(cmd);
  41. else :
  42. cmd = clean_cache_str + " cd ../cache ; cp -r ../archives/resources/code_examples/* . ; " + target_path
  43. os.system(cmd);
  44. if ( target_name == "_xrnlib256.so" ):
  45. all = 0
  46. if ( len(sys.argv) == 2 ) :
  47. if ( sys.argv[1] == "all" ):
  48. all = 1
  49. argvint = 0
  50. else :
  51. argvint = int(sys.argv[1])
  52. if (( len(sys.argv) != 2 ) or ( argvint < 0 ) or ( argvint >= 38 )):
  53. print( "implemented Python examples:" )
  54. print( "0) generate_xrn_matrix_one_third.py" )
  55. print( "1) generate_xrn_matrix_all_rnd.py" )
  56. print( "2) generate_keys_with_wrapper_functions.py" )
  57. print( "3) check_xrn_matrix.py" )
  58. print( "4) split_join_encryption_wrapper.py" )
  59. print( "5) split_join_encryption_bytes_wrapper.py" )
  60. print( "6) encrypt_symmetric_wrapper.py" )
  61. print( "7) encrypt_symmetric_bytes_wrapper.py" )
  62. print( "8) encrypt_asymmetric_wrapper.py" )
  63. print( "9) encrypt_asymmetric_bytes_wrapper.py" )
  64. print( "10) hash_bytes_wrapper.py" )
  65. print( "11) hash_file_wrapper.py" )
  66. print( "12) symmetric_signature_file_wrapper.py" )
  67. print( "13) symmetric_signature_bytes_wrapper.py" )
  68. print( "14) asymmetric_signature_file_wrapper.py" )
  69. print( "15) asymmetric_signature_bytes_wrapper.py" )
  70. print( "16) pseudo_random_number_generator_wrapper.py" )
  71. print( "17) ring_signature_file_wrapper.py" )
  72. print( "18) ring_signature_bytes_wrapper.py" )
  73. print( "19) monomial_key_exchange.py" )
  74. print( "20) certificate_symmetric.py" )
  75. print( "21) certificate_asymmetric.py" )
  76. print( "22) zero_knowledge_proof_binomial_key.py" )
  77. print( "23) zero_knowledge_proof_signature.py" )
  78. print( "24) zero_knowledge_proof_signature_bytes.py" )
  79. print( "25) zero_knowledge_proof_certificate.py" )
  80. print( "26) permute_xrn_matrix_compressed_rnd.py" )
  81. print( "27) permute_xrn_matrix_compressed_deterministic.py" )
  82. print( "28) permute_xrn_matrix_compressed_key.py" )
  83. print( "29) encoding_decoding_file_wrapper.py" )
  84. print( "30) encoding_decoding_bytes_wrapper.py" )
  85. print( "31) polyvalent_key_exchange.py" )
  86. print( "32) checksum_dump_file_wrapper.py" )
  87. print( "33) checksum_dump_bytes_wrapper.py" )
  88. print( "34) create_blocks_from_file.py" )
  89. print( "35) create_blocks_from_bytes.py" )
  90. print( "36) steganography_block_file.py" )
  91. print( "37) steganography_block_bytes.py" )
  92. exit(0)
  93. ordered_script_list = [ "generate_xrn_matrix_one_third.py",
  94. "generate_xrn_matrix_all_rnd.py",
  95. "generate_keys_with_wrapper_functions.py",
  96. "check_xrn_matrix.py",
  97. "split_join_encryption_wrapper.py",
  98. "split_join_encryption_bytes_wrapper.py",
  99. "encrypt_symmetric_wrapper.py",
  100. "encrypt_symmetric_bytes_wrapper.py",
  101. "encrypt_asymmetric_wrapper.py",
  102. "encrypt_asymmetric_bytes_wrapper.py",
  103. "hash_bytes_wrapper.py",
  104. "hash_file_wrapper.py",
  105. "symmetric_signature_file_wrapper.py",
  106. "symmetric_signature_bytes_wrapper.py",
  107. "asymmetric_signature_file_wrapper.py",
  108. "asymmetric_signature_bytes_wrapper.py",
  109. "pseudo_random_number_generator_wrapper.py",
  110. "ring_signature_file_wrapper.py",
  111. "ring_signature_bytes_wrapper.py",
  112. "monomial_key_exchange.py",
  113. "certificate_symmetric.py",
  114. "certificate_asymmetric.py",
  115. "zero_knowledge_proof_binomial_key.py",
  116. "zero_knowledge_proof_signature.py",
  117. "zero_knowledge_proof_signature_bytes.py",
  118. "zero_knowledge_proof_certificate.py",
  119. "permute_xrn_matrix_compressed_rnd.py",
  120. "permute_xrn_matrix_compressed_deterministic.py",
  121. "permute_xrn_matrix_compressed_key.py",
  122. "encoding_decoding_file_wrapper.py",
  123. "encoding_decoding_bytes_wrapper.py",
  124. "polyvalent_key_exchange.py",
  125. "checksum_dump_file_wrapper.py",
  126. "checksum_dump_bytes_wrapper.py",
  127. "create_blocks_from_file.py",
  128. "create_blocks_from_bytes.py",
  129. "steganography_block_file.py",
  130. "steganography_block_bytes.py"
  131. ]
  132. if ( all == 0 ) :
  133. pyscript = ordered_script_list[ argvint ]
  134. print("\nrunning " + pyscript + "\n" )
  135. cmd = clean_cache_str + " cp ./../build/py/_xrnlib256.so ../cache ; cp ./../build/py/xrnlib256.py ../cache ; "
  136. cmd = cmd + " cd ../cache ; cp -r ../archives/resources/code_examples/* . ; "
  137. cmd = cmd + " cp ../code/app/examples/py/" + pyscript + " . ; "
  138. cmd = cmd + " python3 " + pyscript + " ;"
  139. os.system(cmd);
  140. else :
  141. for i in range (len(ordered_script_list)):
  142. print("running "+str(i)+"/"+ str(len(ordered_script_list)))
  143. pyscript = ordered_script_list[ i ]
  144. print("\nrunning " + pyscript + "\n" )
  145. cmd = clean_cache_str + " cp ./../build/py/_xrnlib256.so ../cache ; cp ./../build/py/xrnlib256.py ../cache ; "
  146. cmd = cmd + " cd ../cache ; cp -r ../archives/resources/code_examples/* . ; "
  147. cmd = cmd + " cp ../code/app/examples/py/" + pyscript + " . ; "
  148. cmd = cmd + " python3 " + pyscript + " ;"
  149. print("cmd: "+cmd)
  150. os.system(cmd);