diff --git a/compile_all.py b/compile_all.py index d408c68..b3fc3c9 100755 --- a/compile_all.py +++ b/compile_all.py @@ -8,9 +8,8 @@ import random import subprocess -def build(algo_dir, template_dir): +def build(algo_dir, template_dir, build_dir): # create a new directory for the build - build_dir = None while build_dir is None: r = "%09d" % random.randint(0, 999999999) d = os.path.join("build", r) @@ -121,12 +120,23 @@ def main(argv): for file in f: if file == "api.h": f = os.path.join(r, file) + + # Source directory d d = os.path.split(f)[0] assert os.path.isdir(d) print(d) + + # Test vectors file t t = find_test_vectors(d) print(t) - files.append((t, d)) + + # base name n + pieces = r.split(os.sep) + n = submission + "." + ".".join(pieces[4:]) + print(n) + + # Put all in a tuple and count + files.append((t, d, n)) c += 1 if c == 0: @@ -150,12 +160,13 @@ def main(argv): test_script.write("#!/bin/sh\n") test_script.write("mkdir -p logs\n") test_script.write("mkdir -p measurements\n") - for t, d in files: + for i, (t, d, name) in enumerate(files): print() print(d) try: - b = build(d, template_dir) - test_script.write("echo \"TESTING %s\"\n" % d) + build_dir = os.path.join("build", name) + b = build(d, template_dir, build_dir) + 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, os.path.join(b, 'test'), @@ -164,8 +175,9 @@ def main(argv): ) print("COMPILATION SUCCESS FOR %s" % d) - except Exception: + except Exception as ex: print("COMPILATION FAILED FOR %s" % d) + print(ex) st = os.stat(test_script_path) os.chmod(test_script_path, st.st_mode | stat.S_IEXEC)