diff --git a/process_zip.sh b/process_zip.sh index 3fd9a2a..a9b33a0 100755 --- a/process_zip.sh +++ b/process_zip.sh @@ -64,7 +64,6 @@ function run() { curl \ --request 'POST' \ --header "Content-Type: application/json" \ - --header "Authorization: OAuth ecP9ZsoKMPui4akg1MyGoT7yoGR2bLPo" \ --data "{\"path\":\"$(realpath $TEST_PATH)\",\"template\":\"$TEMPLATE\"}" \ "http://127.0.0.1:5002/schedule_test" diff --git a/templates/bluepill/openocd.cfg b/templates/bluepill/openocd.cfg index d70df06..d0732b8 100644 --- a/templates/bluepill/openocd.cfg +++ b/templates/bluepill/openocd.cfg @@ -21,6 +21,6 @@ source [find target/stm32f1x.cfg] #tpiu config internal swodump.stm32f103-generic.log uart off 72000000 -#reset_config srst_only srst_push_pull srst_nogate connect_assert_srst -reset_config none srst_push_pull srst_nogate +reset_config srst_only srst_push_pull srst_nogate connect_assert_srst +#reset_config none srst_push_pull srst_nogate diff --git a/templates/bluepill/test b/templates/bluepill/test index 12a0adc..a4712a4 100755 --- a/templates/bluepill/test +++ b/templates/bluepill/test @@ -70,6 +70,12 @@ class BluePill(DeviceUnderTestAeadUARTP): eprint(res) assert res == '' + self.ser = serial.Serial( + self.uart_device, + baudrate=115200, + timeout=5) + self.reset() + def reset(self, halt=False): ocd_cmd = 'reset halt' if halt else 'reset run' res = self.ocd.send(ocd_cmd) @@ -77,14 +83,6 @@ class BluePill(DeviceUnderTestAeadUARTP): assert res == '' eprint("Reset!") - def prepare(self): - self.ser = serial.Serial( - self.uart_device, - baudrate=115200, - timeout=5) - self.reset() - DeviceUnderTestAeadUARTP.prepare(self) - def dump_ram(self): res = self.ocd.send( 'dump_image %s 0x20000000 0x%x' % @@ -110,7 +108,8 @@ def main(argv): build_dir = argv[1] kat_path = os.path.join(build_dir, 'LWC_AEAD_KAT.txt') - run_nist_lws_aead_test(kat_path, build_dir, 0x0002, BluePill) + dut = BluePill(build_dir) + run_nist_lws_aead_test(dut, kat_path, build_dir, 0x0002) return 0 diff --git a/templates/esp32/test b/templates/esp32/test index 0db01ba..3157b1b 100755 --- a/templates/esp32/test +++ b/templates/esp32/test @@ -46,14 +46,6 @@ class ESP32(DeviceUnderTestAeadUARTP): self.ser.setRTS(False) # EN=HIGH, chip out of reset time.sleep(1) - def prepare(self): - self.ser = serial.Serial( - self.uart_device, - baudrate=500000, - timeout=5) - self.reset() - DeviceUnderTestAeadUARTP.prepare(self) - def flash(self): pio_packages_path = "/home/tester/.platformio/packages/" esptoolpy_path = os.path.join( @@ -94,6 +86,12 @@ class ESP32(DeviceUnderTestAeadUARTP): eprint("Firmware flashed.") + self.ser = serial.Serial( + self.uart_device, + baudrate=500000, + timeout=5) + self.reset() + def dump_ram(self): return None @@ -106,7 +104,8 @@ def main(argv): build_dir = argv[1] kat_path = os.path.join(build_dir, 'LWC_AEAD_KAT.txt') - run_nist_lws_aead_test(kat_path, build_dir, 0x0020, ESP32) + dut = ESP32(build_dir) + run_nist_lws_aead_test(dut, kat_path, build_dir, 0x0020) return 0 diff --git a/templates/f7/test b/templates/f7/test index 387fced..7514ca4 100755 --- a/templates/f7/test +++ b/templates/f7/test @@ -70,7 +70,8 @@ def main(argv): build_dir = argv[1] kat_path = os.path.join(build_dir, 'LWC_AEAD_KAT.txt') - run_nist_lws_aead_test(kat_path, build_dir, 0x0008, F7) + dut = F7(build_dir) + run_nist_lws_aead_test(dut, kat_path, build_dir, 0x0008) return 0 diff --git a/templates/maixduino/test b/templates/maixduino/test index 1d38870..6ef5923 100755 --- a/templates/maixduino/test +++ b/templates/maixduino/test @@ -54,11 +54,6 @@ class Maixduino(DeviceUnderTestAeadUARTP): self.ser.setRTS(True) time.sleep(1) - def prepare(self): - self.reset() - self.reset() - DeviceUnderTestAeadUARTP.prepare(self) - def flash(self): pio_packages_path = "/home/tester/.platformio/packages/" kflash_path = os.path.join( @@ -73,6 +68,9 @@ class Maixduino(DeviceUnderTestAeadUARTP): eprint("Firmware flashed.") + self.reset() + self.reset() + def dump_ram(self): return None @@ -85,7 +83,8 @@ def main(argv): build_dir = argv[1] kat_path = os.path.join(build_dir, 'LWC_AEAD_KAT.txt') - run_nist_lws_aead_test(kat_path, build_dir, 0x0080, Maixduino) + dut = Maixduino(build_dir) + run_nist_lws_aead_test(dut, kat_path, build_dir, 0x0080) return 0 diff --git a/templates/uno/test b/templates/uno/test index 6a21ba8..b6c8077 100755 --- a/templates/uno/test +++ b/templates/uno/test @@ -44,14 +44,6 @@ class Uno(DeviceUnderTestAeadUARTP): self.ser.setDTR(False) time.sleep(1) - def prepare(self): - self.ser = serial.Serial( - self.uart_device, - baudrate=115200, - timeout=5) - self.reset() - DeviceUnderTestAeadUARTP.prepare(self) - def flash(self): pipe = subprocess.PIPE avrdude_dir = '/home/tester/.platformio/packages/tool-avrdude/' @@ -81,6 +73,12 @@ class Uno(DeviceUnderTestAeadUARTP): assert p.returncode == 0 eprint("Firmware flashed.") + self.ser = serial.Serial( + self.uart_device, + baudrate=115200, + timeout=5) + self.reset() + def dump_ram(self): return None @@ -93,7 +91,8 @@ def main(argv): build_dir = argv[1] kat_path = os.path.join(build_dir, 'LWC_AEAD_KAT.txt') - run_nist_lws_aead_test(kat_path, build_dir, 0x0800, Uno) + dut = Uno(build_dir) + run_nist_lws_aead_test(dut, kat_path, build_dir, 0x0800) return 0 diff --git a/test-dude.py b/test-dude.py index 76e734c..0eda497 100644 --- a/test-dude.py +++ b/test-dude.py @@ -87,19 +87,27 @@ class Runner(threading.Thread): cmd += self.program cmd += [self.job.path] print("Executing ``%s´´" % ' '.join(cmd)) - out_fd = open(os.path.join(self.job.path, 'test.stdout.log'), 'w') - err_fd = open(os.path.join(self.job.path, 'test.stderr.log'), 'w') - self.process = subprocess.Popen( - cmd, - stdout=out_fd, - stderr=err_fd - ) - self.process.wait() + out_path = os.path.join(self.job.path, 'test.stdout.log') + err_path = os.path.join(self.job.path, 'test.stderr.log') + with open(out_path, 'w') as out_fd, \ + open(err_path, 'w') as err_fd: + self.process = subprocess.Popen( + cmd, + stdout=out_fd, + stderr=err_fd + ) + self.process.wait() + if self.process.returncode == 0: self.job.state = 'SUCCESSFUL' else: self.job.state = 'FAILED' self.process = None + + subprocess.check_call( + ['zip', '-r', 'results.zip', '.'], + cwd=self.job.path) + self.job = None diff --git a/test_common.py b/test_common.py index 9c1039b..b88ef43 100644 --- a/test_common.py +++ b/test_common.py @@ -449,29 +449,17 @@ class OpenOcd: return data.decode('ascii') -def run_nist_lws_aead_test(vectors_file, build_dir, - logic_mask=0xffff, - basecls=DeviceUnderTestAeadUARTP, - results_path=None): - results = {} +def run_nist_lws_aead_test(dut, vectors_file, build_dir, + logic_mask=0xffff): kat = list(parse_nist_aead_test_vectors(vectors_file)) - results['test_vectors'] = kat - - dut = basecls(build_dir) - - fw_path = dut.firmware_path - if fw_path is not None: - with open(fw_path, 'rb') as fw_file: - firmware = fw_file.read() - results['firmware'] = (fw_path, os.stat(fw_path), firmware) dut.flash() dut.prepare() sys.stdout.write("Board prepared\n") sys.stdout.flush() - dump_a = dut.dump_ram() + ram_dumps = [dut.dump_ram()] tool = LogicMultiplexerTimeMeasurements(logic_mask) try: @@ -482,10 +470,10 @@ def run_nist_lws_aead_test(vectors_file, build_dir, run_nist_aead_test_line(dut, i, m, ad, k, npub, c) tool.unarm() - if i == 1 and dump_a is not None: - dump_b = dut.dump_ram() - results['ram_dumps'] = [dump_a, dump_b] - longest = compare_dumps(dump_a, dump_b) + if i == 1 and ram_dumps[0] is not None: + ram_dumps.append(dut.dump_ram()) + + longest = compare_dumps(ram_dumps[0], ram_dumps[1]) print(" longest chunk of untouched memory = %d" % longest) except Exception as ex: @@ -495,12 +483,15 @@ def run_nist_lws_aead_test(vectors_file, build_dir, finally: tool.end_measurement() - results['time_dips'] = tool.capture - - if results_path is None: - results_path = os.path.join(build_dir, 'results.pickle') - if results_path is not False: - with open(results_path, 'wb') as f: - pickle.dump(results, f, pickle.HIGHEST_PROTOCOL) - - return results + for i, d in enumerate(ram_dumps): + path = os.path.join(build_dir, 'ram_dump.%d.bin' % i) + if d is not None: + with open(path, 'wb') as f: + f.write(d) + + logic_trace = tool.capture + path = os.path.join(build_dir, 'logic_trace.csv') + with open(path, 'wt') as f: + print("TIME,VALUE", file=f) + for t, v in logic_trace: + print("%f,0x%x" % (t, v), file=f)