From 00c79c4b38acff9f82d0698035d454feddd3e814 Mon Sep 17 00:00:00 2001 From: lwc-tester Date: Tue, 3 Mar 2020 17:08:35 +0100 Subject: [PATCH] aaaaaaaaaaaaaaa --- compile_all.py | 1 - process_zip.sh | 31 ++++++++++++++++++++++--------- templates/f7/test | 2 +- test_scheduler.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 11 deletions(-) create mode 100755 test_scheduler.py diff --git a/compile_all.py b/compile_all.py index a2f7c9d..97b0e44 100755 --- a/compile_all.py +++ b/compile_all.py @@ -214,7 +214,6 @@ def main(argv): print() print() - print("Now execute ' %s ' to start the test" % test_script_path) if __name__ == "__main__": diff --git a/process_zip.sh b/process_zip.sh index 80dc91e..fd19078 100755 --- a/process_zip.sh +++ b/process_zip.sh @@ -2,6 +2,7 @@ shopt -s extglob +export PYTHONPATH="$PYTHONPATH:$(pwd)" function run() { TEMPLATE="$1" @@ -31,28 +32,38 @@ function run() { ./compile_all.py -t "templates/$TEMPLATE" -b "$TMPDIR" for cipher in $TMPDIR/*; do - CIPHER_SLUG=$(basename $cipher) if [[ ! -d $cipher ]]; then continue; fi - mkdir -p $DESTDIR/$CIPHER_SLUG || exit 1 - mv $cipher/*.log $DESTDIR/$CIPHER_SLUG/ + + mkdir -p "./queues" + QUEUE_PATH="./queues/$TEMPLATE" + TEST_PATH="$DESTDIR/$CIPHER_SLUG" + CIPHER_SLUG=$(basename $cipher) + + mkdir -p "$TEST_PATH" || exit 1 + mv $cipher/*.log "$TEST_PATH" + mv "$cipher/LWC_AEAD_KAT.txt" "$TEST_PATH" case $TEMPLATE in - f7) mv $cipher/build/f7.* $DESTDIR/$CIPHER_SLUG/ + f7) mv $cipher/build/f7.* "$TEST_PATH" ;; - maixduino) mv $cipher/.pio/build/sipeed-maixduino/firmware.* $DESTDIR/$CIPHER_SLUG/ + maixduino) mv $cipher/.pio/build/sipeed-maixduino/firmware.* "$TEST_PATH" ;; - bluepill) mv $cipher/.pio/build/bluepill_f103c8/firmware.* $DESTDIR/$CIPHER_SLUG/ + bluepill) mv $cipher/.pio/build/bluepill_f103c8/firmware.* "$TEST_PATH" ;; - uno) mv $cipher/.pio/build/uno/firmware.* $DESTDIR/$CIPHER_SLUG/ + uno) mv $cipher/.pio/build/uno/firmware.* "$TEST_PATH" ;; - esp32) mv $cipher/.pio/build/esp32dev/firmware.* $DESTDIR/$CIPHER_SLUG/ + esp32) mv $cipher/.pio/build/esp32dev/firmware.* $cipher/.pio/build/esp32dev/partitions.bin "$TEST_PATH" ;; esac + CMD="PYTHONPATH=\$PYTHONPATH:$(pwd) python3 './templates/$TEMPLATE/test' '$TEST_PATH' > '$TEST_PATH/test.stdout.log' 2> '$TEST_PATH/test.stderr.log'" + printf -v CMD "%q" "$CMD" + flock "$QUEUE_PATH" bash -c "echo $CMD >> \"$QUEUE_PATH\"" + done rm -rf "$TMPDIR" @@ -69,13 +80,15 @@ else MAINDIR=email-submissions/$(date +%Y-%m-%d-%H:%M) mkdir -p $MAINDIR - unzip $ZIP_PATH -d all-lwc-submission-files + TMPDIR=$(mktemp -d -t submission-XXXXXXXXXX) + unzip $ZIP_PATH -d $TMPDIR for i in templates/*; do TEMPLATE="${i##*/}" echo "Template is $TEMPLATE" touch $MAINDIR/locky.lock flock $MAINDIR/locky.lock $0 run $TEMPLATE $MAINDIR/$TEMPLATE done + rm -rf $TMPDIR fi diff --git a/templates/f7/test b/templates/f7/test index 8981e98..7b6f8f6 100755 --- a/templates/f7/test +++ b/templates/f7/test @@ -17,7 +17,7 @@ def get_serial(): devices = [ p.device for p in ports - if p.serial_number == 'FT2XA9MY' + if p.serial_number == '00000000' ] devices.sort() return serial.Serial( diff --git a/test_scheduler.py b/test_scheduler.py new file mode 100755 index 0000000..e88f02a --- /dev/null +++ b/test_scheduler.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 +import sys +import time +import fcntl +import subprocess + + +def file_pop_line(path): + try: + with open(path, 'rt+') as q: + fcntl.lockf(q, fcntl.LOCK_EX) + first = q.readline() + if first == '': + return None + rest = q.read() + q.seek(0) + q.write(rest) + q.truncate() + return first + except FileNotFoundError: + return None + + +def main(argv): + test_queue = argv[1] + + while 1: + cmd = file_pop_line(test_queue).strip() + + if cmd is None: + time.sleep(5) + else: + print() + print("Executing %s" % cmd) + p = subprocess.Popen(['bash', '-c', cmd]) + p.wait() + print() + print("Return code is %d" % p.returncode) + print() + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) -- libgit2 0.26.0