Commit 69d96640 by Enrico Pozzobon

less complicated test.py and less aggressive compile_all.py

parent b5fadc28
...@@ -9,6 +9,9 @@ import subprocess ...@@ -9,6 +9,9 @@ import subprocess
def build(algo_dir, template_dir, build_dir): def build(algo_dir, template_dir, build_dir):
if os.path.isdir(build_dir):
return None
# create a new directory for the build # create a new directory for the build
while build_dir is None: while build_dir is None:
r = "%09d" % random.randint(0, 999999999) r = "%09d" % random.randint(0, 999999999)
...@@ -172,10 +175,8 @@ def main(argv): ...@@ -172,10 +175,8 @@ def main(argv):
#files = files[:1] #files = files[:1]
print("%d algorithms will be compiled" % len(files)) print("%d algorithms will be compiled" % len(files))
# Clear the build directory as it is a leftover from the previous execution if not os.path.isdir('build'):
if os.path.isdir('build'): os.mkdir('build')
shutil.rmtree('build')
os.mkdir('build')
print() print()
...@@ -191,6 +192,8 @@ def main(argv): ...@@ -191,6 +192,8 @@ def main(argv):
try: try:
build_dir = os.path.join("build", name) build_dir = os.path.join("build", name)
b = build(d, template_dir, build_dir) 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("\n\necho \"TEST NUMBER %03d: TESTING %s\"\n" % (i, d))
test_script.write("python3 -u ./test.py %s %s 2> %s | tee %s\n" % ( test_script.write("python3 -u ./test.py %s %s 2> %s | tee %s\n" % (
t, t,
......
...@@ -6,8 +6,6 @@ import sys ...@@ -6,8 +6,6 @@ import sys
import struct import struct
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
MEASURE_TIME = True
MEASURE_RAM = False
def main(argv): def main(argv):
if len(argv) < 3: if len(argv) < 3:
...@@ -18,13 +16,11 @@ def main(argv): ...@@ -18,13 +16,11 @@ def main(argv):
for attempt in range(3): for attempt in range(3):
print("beginning test %d of '%s' using test vectors '%s'" % (attempt, ' '.join(cmd), argv[1])) print("beginning test %d of '%s' using test vectors '%s'" % (attempt, ' '.join(cmd), argv[1]))
try: try:
if MEASURE_TIME: measurements = begin_measurement()
measurements = begin_measurement()
try: try:
test(argv[1], cmd) test(argv[1], cmd)
finally: finally:
if MEASURE_TIME: end_measurement(measurements)
end_measurement(measurements)
print("TEST SUCCESSFUL") print("TEST SUCCESSFUL")
return 0 return 0
...@@ -118,12 +114,6 @@ def test(test_file, cmd): ...@@ -118,12 +114,6 @@ def test(test_file, cmd):
print(" m = %s" % output.hex()) print(" m = %s" % output.hex())
if m != output: if m != output:
raise Exception("output of encryption is different from expected ciphertext") raise Exception("output of encryption is different from expected ciphertext")
if MEASURE_RAM:
write(b'u')
output = obtain()
print(" untouched memory = %d" % struct.unpack("<I", output))
break
elif res is not None: elif res is not None:
if res[1].lower() == 'count': if res[1].lower() == 'count':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment