Commit f06d7886 by Enrico Pozzobon

work in progress in new test setup

parent 30d6aa6a
...@@ -4,19 +4,13 @@ import os ...@@ -4,19 +4,13 @@ import os
import sys import sys
import stat import stat
import shutil import shutil
import random
import subprocess import subprocess
def build(algo_dir, template_dir, build_dir): def build(algo_dir, template_dir, build_dir):
# create a new directory for the build # create a new directory for the build
while build_dir is None:
r = "%09d" % random.randint(0, 999999999)
d = os.path.join("build", r)
if not os.path.isdir(d):
build_dir = d
print("Building in %s" % build_dir) print("Building in %s" % build_dir)
# copy all the files from the submitted algorithm into the build directory # copy all the files from the submitted algorithm into the build directory
shutil.copytree(algo_dir, build_dir) shutil.copytree(algo_dir, build_dir)
...@@ -69,7 +63,6 @@ def build(algo_dir, template_dir, build_dir): ...@@ -69,7 +63,6 @@ def build(algo_dir, template_dir, build_dir):
p.wait() p.wait()
assert p.returncode == 0 assert p.returncode == 0
finally: finally:
sys.stdout.flush() sys.stdout.flush()
sys.stderr.flush() sys.stderr.flush()
...@@ -101,6 +94,7 @@ def find_test_vectors(d): ...@@ -101,6 +94,7 @@ def find_test_vectors(d):
def main(argv): def main(argv):
submissions_dir = "all-lwc-submission-files" submissions_dir = "all-lwc-submission-files"
template_dir = "templates/linux" template_dir = "templates/linux"
build_dir = 'build'
include_list = None include_list = None
if len(argv) > 1: if len(argv) > 1:
template_dir = argv[1] template_dir = argv[1]
...@@ -115,7 +109,8 @@ def main(argv): ...@@ -115,7 +109,8 @@ def main(argv):
# get all the submissions by looking for files named "api.h" # get all the submissions by looking for files named "api.h"
subfiles = [] subfiles = []
for submission in subs: for submission in subs:
implementations_dir = os.path.join(submissions_dir, submission, "Implementations", "crypto_aead") implementations_dir = os.path.join(
submissions_dir, submission, "Implementations", "crypto_aead")
if not os.path.isdir(implementations_dir): if not os.path.isdir(implementations_dir):
continue continue
...@@ -157,30 +152,28 @@ def main(argv): ...@@ -157,30 +152,28 @@ def main(argv):
pieces = f.split(os.sep) pieces = f.split(os.sep)
n = pieces[1] + "." + ".".join(pieces[4:-1]) n = pieces[1] + "." + ".".join(pieces[4:-1])
print(n) print(n)
# if include_list was provided, skip elements not in the list # if include_list was provided, skip elements not in the list
if include_list is not None: if include_list is not None:
if not n in include_list: if n not in include_list:
continue continue
# Put all in a tuple and count # Put all in a tuple and count
files.append((t, d, n)) files.append((t, d, n))
# For testing, we only do the first 1 # For testing, we only do the first 1
#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 # Clear the build directory as it is a leftover from the previous execution
if os.path.isdir('build'): if os.path.isdir(build_dir):
shutil.rmtree('build') shutil.rmtree(build_dir)
os.mkdir('build') os.mkdir(build_dir)
print() print()
# Write a script that executes all the tests one after the other # Write a script that executes all the tests one after the other
test_script_path = os.path.join("build", "test_all.sh") test_script_path = os.path.join(build_dir, "test_all.sh")
with open(test_script_path, 'w') as test_script: with open(test_script_path, 'w') as test_script:
test_script.write("#!/bin/sh\n") test_script.write("#!/bin/sh\n")
test_script.write("mkdir -p logs\n") test_script.write("mkdir -p logs\n")
...@@ -189,10 +182,13 @@ def main(argv): ...@@ -189,10 +182,13 @@ def main(argv):
print() print()
print(d) print(d)
try: try:
build_dir = os.path.join("build", name) b = build(d, template_dir, os.path.join(build_dir, name))
b = build(d, template_dir, build_dir) if b is None:
test_script.write("\n\necho \"TEST NUMBER %03d: TESTING %s\"\n" % (i, d)) continue
test_script.write("python3 -u ./test.py %s %s 2> %s | tee %s\n" % ( 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, t,
os.path.join(b, 'test'), os.path.join(b, 'test'),
os.path.join(b, 'test_stderr.log'), os.path.join(b, 'test_stderr.log'),
......
...@@ -112,7 +112,7 @@ class UARTP: ...@@ -112,7 +112,7 @@ class UARTP:
tag_old = tag tag_old = tag
tag = self.uart_read() tag = self.uart_read()
tag_old = tag tag_old = tag
l = self.uart_read() l = self.uart_read()
if l & 0x80: if l & 0x80:
l &= 0x7f l &= 0x7f
...@@ -137,6 +137,7 @@ class UARTP: ...@@ -137,6 +137,7 @@ class UARTP:
else: else:
return buf return buf
def main(argv): def main(argv):
eprint(argv[0]) eprint(argv[0])
script_dir = os.path.split(argv[0])[0] script_dir = os.path.split(argv[0])[0]
...@@ -238,8 +239,7 @@ def main(argv): ...@@ -238,8 +239,7 @@ def main(argv):
else: else:
raise Exception("Unknown action %c" % action) raise Exception("Unknown action %c" % action)
return 0 return 0
......
This diff is collapsed. Click to expand it.
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