reg_list = inst_test_suite.get_registers() # Fixes the bytestring issue in unicorn for the test genration int_list = inst_test_suite.get_bytestr() bytecode = bytearray(int_list) # Unicorn output file unicorn_output_file_name = inst_test_suite.get_hexstring() op_fileptr = open(output_dir + unicorn_output_file_name, "w") bitstring = inst_test_suite.get_pvs_bitstring() hexstring = unicorn_output_file_name # Add more info to the file for repeating the test case using the bitstring, hexstring , int_list combination op_fileptr.write("input_bitstring=" + bitstring + "\n") op_fileptr.write("input_hexstring=" + hexstring + "\n") op_fileptr.write("reg_list=" + str(reg_list) + "\n") op_fileptr.write("int_list=" + str(int_list) + "\n") # Run the instruction mtest.test_arm64(bytes(bytecode), op_fileptr, reg_list, item) # Code for generating the pvs lemma file from the unicorn output file pvs_lemma_filename = inst_name + "_" + unicorn_output_file_name pvs_lemma_filename = pvs_lemma_filename.upper() pg = pvs_lemma_generator(pvs_lemma_filename) # This sets the name of the inout file for pvs lemma generator to the output file generated by unicorn pg.set_name_inputfile(unicorn_output_file_name) pg.parse_unicorn_output_file() pg.generate_pvs_lemma_file() print "Generating " + pvs_lemma_filename + ".pvs" generate_pvs = tc.test_concrete(bitstring, hexstring) # print "Generating the test_concrete file for the instruction" # generate_pvs.extract_inst_class() # generate_pvs.extract_theory_parameters() # inst_imm.view_fields() # generate_pvs.generate_pvs_code()
reg_list = inst_test_suite.get_registers() # Fixes the bytestring issue in unicorn for the test genration int_list = inst_test_suite.get_bytestr() bytecode = bytearray(int_list) # Unicorn output file unicorn_output_file_name = inst_test_suite.get_hexstring() op_fileptr = open(output_dir + unicorn_output_file_name, "w") bitstring = inst_test_suite.get_pvs_bitstring() hexstring = unicorn_output_file_name # Add more info to the file for repeating the test case using the bitstring, hexstring , int_list combination op_fileptr.write("input_bitstring=" + bitstring + "\n") op_fileptr.write("input_hexstring=" + hexstring + "\n") op_fileptr.write("reg_list=" + str(reg_list) + "\n") op_fileptr.write("int_list=" + str(int_list) + "\n") # Run the instruction post_state = mtest.test_arm64(bytes(bytecode), op_fileptr, reg_list, bitstring) # Code for generating the pvs lemma file from the unicorn output file pvs_lemma_filename = inst_name + "_" + unicorn_output_file_name pvs_lemma_filename = pvs_lemma_filename.upper() pg = pvs_lemma_generator(pvs_lemma_filename) # This sets the name of the inout file for pvs lemma generator to the output file generated by unicorn pg.set_name_inputfile(unicorn_output_file_name) pg.parse_unicorn_output_file() pg.generate_pvs_lemma_file(post_state) print "Generating " + pvs_lemma_filename + ".pvs" generate_pvs = tc.test_concrete(bitstring, hexstring) ############################################################## ## Decoupling the concrete file generation logic from the test_lemma generator
reg_list = inst_test_suite.get_registers() # Fixes the bytestring issue in unicorn for the test genration int_list = inst_test_suite.get_bytestr() bytecode = bytearray(int_list) # Unicorn output file unicorn_output_file_name = inst_test_suite.get_hexstring() op_fileptr = open(output_dir + unicorn_output_file_name, "w") bitstring = inst_test_suite.get_pvs_bitstring() hexstring = unicorn_output_file_name # Add more info to the file for repeating the test case using the bitstring, hexstring , int_list combination op_fileptr.write("input_bitstring=" + bitstring + "\n") op_fileptr.write("input_hexstring=" + hexstring + "\n") op_fileptr.write("reg_list=" + str(reg_list) + "\n") op_fileptr.write("int_list=" + str(int_list) + "\n") # Run the instruction post_state, final_address = mtest.test_arm64(bytes(bytecode), op_fileptr, reg_list, bitstring) # Code for generating the pvs lemma file from the unicorn output file pvs_lemma_filename = inst_name + "_" + unicorn_output_file_name pvs_lemma_filename = pvs_lemma_filename.upper() pg = pvs_lemma_generator(pvs_lemma_filename) # This sets the name of the inout file for pvs lemma generator to the output file generated by unicorn pg.set_name_inputfile(unicorn_output_file_name) pg.parse_unicorn_output_file() pg.generate_pvs_lemma_file(post_state, final_address) print "Generating " + pvs_lemma_filename + ".pvs" generate_pvs = tc.test_concrete(bitstring, hexstring) ############################################################## ## Decoupling the concrete file generation logic from the test_lemma generator