From 69d9664040f76899f9b2b4b03ddc4f37016ac412 Mon Sep 17 00:00:00 2001 From: Enrico Pozzobon Date: Sun, 28 Jul 2019 01:50:08 +0200 Subject: [PATCH] less complicated test.py and less aggressive compile_all.py --- compile_all.py | 11 +++++++---- test.py | 14 ++------------ 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/compile_all.py b/compile_all.py index d209752..44235b2 100755 --- a/compile_all.py +++ b/compile_all.py @@ -9,6 +9,9 @@ import subprocess def build(algo_dir, template_dir, build_dir): + if os.path.isdir(build_dir): + return None + # create a new directory for the build while build_dir is None: r = "%09d" % random.randint(0, 999999999) @@ -172,10 +175,8 @@ def main(argv): #files = files[:1] print("%d algorithms will be compiled" % len(files)) - # Clear the build directory as it is a leftover from the previous execution - if os.path.isdir('build'): - shutil.rmtree('build') - os.mkdir('build') + if not os.path.isdir('build'): + os.mkdir('build') print() @@ -191,6 +192,8 @@ def main(argv): try: build_dir = os.path.join("build", name) b = build(d, template_dir, build_dir) + if b is None: + continue test_script.write("\n\necho \"TEST NUMBER %03d: TESTING %s\"\n" % (i, d)) test_script.write("python3 -u ./test.py %s %s 2> %s | tee %s\n" % ( t, diff --git a/test.py b/test.py index 5de8fee..07bd135 100755 --- a/test.py +++ b/test.py @@ -6,8 +6,6 @@ import sys import struct from subprocess import Popen, PIPE -MEASURE_TIME = True -MEASURE_RAM = False def main(argv): if len(argv) < 3: @@ -18,13 +16,11 @@ def main(argv): for attempt in range(3): print("beginning test %d of '%s' using test vectors '%s'" % (attempt, ' '.join(cmd), argv[1])) try: - if MEASURE_TIME: - measurements = begin_measurement() + measurements = begin_measurement() try: test(argv[1], cmd) finally: - if MEASURE_TIME: - end_measurement(measurements) + end_measurement(measurements) print("TEST SUCCESSFUL") return 0 @@ -118,12 +114,6 @@ def test(test_file, cmd): print(" m = %s" % output.hex()) if m != output: raise Exception("output of encryption is different from expected ciphertext") - - if MEASURE_RAM: - write(b'u') - output = obtain() - print(" untouched memory = %d" % struct.unpack("