def run_execution_test(self, romfilename_hex, stdin_filename): with open(romfilename_hex, 'r') as romfile_hex: write_binary_filefd_from_hex0_filefd( romfile_hex, self.binary_rom) self.binary_rom.close() with open(stdin_filename, 'rb') as input_file_fd: self.finish_setup(input_file_fd) self.do_state_checks() while True: debug_tuple = self.advance_both_vms() if self.halted(): break # don't bother with state checks after HALT self.do_state_checks(debug_tuple) self.assertTrue( file_compare(self.tape_01_filename, LILITH_TAPE_NAME_01, shallow=False), "%s vs %s" % (self.tape_01_filename, LILITH_TAPE_NAME_01) ) self.assertTrue( file_compare(self.tape_02_filename, LILITH_TAPE_NAME_02, shallow=False), "%s vs %s" % (self.tape_02_filename, LILITH_TAPE_NAME_02) )
def mark_on_disk(disk_name, log, flag, back_skip, mark_files): """ Copy 512 Bytes random data to specified disk address as a mark. Or to read the marks from disk for verification :param disk_name: disk name that be copied data to. :param log: an opened file object to store stdout and stderr :param flag: a flag to choose mark creation or verification action :return: """ # Raw data will be restored in document mark_data, size is 512 byte # Contents of mark_data will be write to both front/back end of disk addresses commands = [["dd", "if=/dev/urandom", "of=" + mark_files[0], "count=1"], [ "dd", "if=" + mark_files[0], "of=" + disk_name, "seek=" + FRONT_SKIP, "count=1" ], [ "dd", "if=" + mark_files[0], "of=" + disk_name, "seek=" + back_skip, "count=1" ], [ "dd", "if=" + disk_name, "of=" + mark_files[1], "skip=" + FRONT_SKIP, "count=1" ], [ "dd", "if=" + disk_name, "of=" + mark_files[2], "skip=" + back_skip, "count=1" ]] if not flag: # Create marks for command in commands: exit_status = robust_check_call(command, log) assert exit_status[ "exit_code"] == 0, "Command [ %s ] failed" % " ".join(command) assert file_compare(mark_files[0], mark_files[1]), \ "Disk front mark data is not written correctly" assert file_compare(mark_files[0], mark_files[2]), \ "Disk back mark data is not written correctly" else: # Verify marks for command in commands[3:5]: exit_status = robust_check_call(command, log) assert exit_status[ "exit_code"] == 0, "Command [ %s ] failed" % " ".join(command) assert not file_compare(mark_files[0], mark_files[1]), \ "Disk front mark data exists after erasing" assert not file_compare(mark_files[0], mark_files[2]), \ "Disk back mark data exists after erasing" return
def mark_on_disk(disk_name, log, flag, back_skip, mark_files): """ Copy 512 Bytes random data to specified disk address as a mark. Or to read the marks from disk for verification :param disk_name: disk name that be copied data to. :param log: an opened file object to store stdout and stderr :param flag: a flag to choose mark creation or verification action :return: """ # Raw data will be restored in document mark_data, size is 512 byte # Contents of mark_data will be write to both front/back end of disk addresses commands = [ ["dd", "if=/dev/urandom", "of=" + mark_files[0], "count=1"], ["dd", "if=" + mark_files[0], "of=" + disk_name, "seek=" + FRONT_SKIP, "count=1"], ["dd", "if=" + mark_files[0], "of=" + disk_name, "seek=" + back_skip, "count=1"], ["dd", "if=" + disk_name, "of=" + mark_files[1], "skip=" + FRONT_SKIP, "count=1"], ["dd", "if=" + disk_name, "of=" + mark_files[2], "skip=" + back_skip, "count=1"] ] if not flag: # Create marks for command in commands: exit_status = robust_check_call(command, log) assert exit_status["exit_code"] == 0, "Command [ %s ] failed" % " ".join(command) assert file_compare(mark_files[0], mark_files[1]), \ "Disk front mark data is not written correctly" assert file_compare(mark_files[0], mark_files[2]), \ "Disk back mark data is not written correctly" else: # Verify marks for command in commands[3:5]: exit_status = robust_check_call(command, log) assert exit_status["exit_code"] == 0, "Command [ %s ] failed" % " ".join(command) assert not file_compare(mark_files[0], mark_files[1]), \ "Disk front mark data exists after erasing" assert not file_compare(mark_files[0], mark_files[2]), \ "Disk back mark data exists after erasing" return