Commit a7239a02 by Enrico Pozzobon

trying to make test measurements more stable

parent f68f7f7e
...@@ -156,13 +156,12 @@ def main(argv): ...@@ -156,13 +156,12 @@ def main(argv):
try: try:
b = build(d, template_dir) b = build(d, template_dir)
test_script.write("echo \"TESTING %s\"\n" % d) test_script.write("echo \"TESTING %s\"\n" % d)
test_script.write("./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,
os.path.join(b, 'test'), os.path.join(b, 'test'),
os.path.join(b, 'test_stderr.log'), os.path.join(b, 'test_stderr.log'),
os.path.join(b, 'test_stdout.log')) os.path.join(b, 'test_stdout.log'))
)
#./test.py all-lwc-submission-files/tinyjambu/Implementations/crypto_aead/tinyjambu192/LWC_AEAD_KAT_192_96.txt build/731759111/test 2> build/731759111/test_stderr.log | tee build/731759111/test_stdout.log
print("COMPILATION SUCCESS FOR %s" % d) print("COMPILATION SUCCESS FOR %s" % d)
except Exception: except Exception:
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#define MAX_BYTES 100 #define MAX_BYTES 100
//#define DEBUG //#define DEBUG
#define CRYPTO_BUSY 12
uint8_t npub[CRYPTO_NPUBBYTES]; uint8_t npub[CRYPTO_NPUBBYTES];
uint8_t nsec[CRYPTO_NSECBYTES]; uint8_t nsec[CRYPTO_NSECBYTES];
...@@ -70,8 +71,8 @@ void assert(bool b) { ...@@ -70,8 +71,8 @@ void assert(bool b) {
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT); pinMode(CRYPTO_BUSY, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH); digitalWrite(CRYPTO_BUSY, HIGH);
delay(100); delay(100);
Serial.print("Hello, World!"); Serial.print("Hello, World!");
} }
...@@ -98,18 +99,18 @@ void loop() { ...@@ -98,18 +99,18 @@ void loop() {
case 'e': case 'e':
noInterrupts(); noInterrupts();
asm("nop"); asm("nop");
digitalWrite(LED_BUILTIN, LOW); digitalWrite(CRYPTO_BUSY, LOW);
res = crypto_aead_encrypt(c, &clen, m, mlen, ad, adlen, nsec, npub, k); res = crypto_aead_encrypt(c, &clen, m, mlen, ad, adlen, nsec, npub, k);
digitalWrite(LED_BUILTIN, HIGH); digitalWrite(CRYPTO_BUSY, HIGH);
asm("nop"); asm("nop");
interrupts(); interrupts();
break; break;
case 'd': case 'd':
noInterrupts(); noInterrupts();
asm("nop"); asm("nop");
digitalWrite(LED_BUILTIN, LOW); digitalWrite(CRYPTO_BUSY, LOW);
res = crypto_aead_decrypt(m, &mlen, nsec, c, clen, ad, adlen, npub, k); res = crypto_aead_decrypt(m, &mlen, nsec, c, clen, ad, adlen, npub, k);
digitalWrite(LED_BUILTIN, HIGH); digitalWrite(CRYPTO_BUSY, HIGH);
asm("nop"); asm("nop");
interrupts(); interrupts();
break; break;
......
...@@ -15,17 +15,19 @@ def main(argv): ...@@ -15,17 +15,19 @@ 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:
measurements = begin_measurement() measurements = begin_measurement()
try: try:
test(argv[1], cmd) test(argv[1], cmd)
finally:
end_measurement(measurements)
print("TEST SUCCESSFUL") print("TEST SUCCESSFUL")
return 0 return 0
except Exception as ex: except Exception as ex:
print(str(ex)) print(str(ex))
print("TEST FAILED") print("TEST FAILED")
finally: finally:
end_measurement(measurements)
sys.stdout.flush() sys.stdout.flush()
sys.stderr.flush() sys.stderr.flush()
...@@ -135,19 +137,24 @@ def begin_measurement(): ...@@ -135,19 +137,24 @@ def begin_measurement():
import saleae import saleae
import time import time
sal = saleae.Saleae() sal = saleae.Saleae()
sal.set_active_channels([0, 1], []) sal.set_active_channels([0, 1, 2, 3], [])
sal.set_sample_rate(sal.get_all_sample_rates()[0]) sal.set_sample_rate(sal.get_all_sample_rates()[0])
sal.set_capture_seconds(6000) sal.set_capture_seconds(1000)
sal.capture_start() sal.capture_start()
time.sleep(1) time.sleep(1)
if sal.is_processing_complete():
raise Exception("Capture didn't start successfully")
return sal return sal
def end_measurement(sal): def end_measurement(sal):
import time import time
time.sleep(1) time.sleep(1)
sal.capture_stop(); sal.capture_stop();
while not sal.is_processing_complete(): for attempt in range(3):
pass if not sal.is_processing_complete():
print("waiting for capture to complete")
time.sleep(1)
continue
outfile = "measurement_%s.csv" % time.strftime("%Y%m%d-%H%M%S") outfile = "measurement_%s.csv" % time.strftime("%Y%m%d-%H%M%S")
outfile = os.path.join("measurements", outfile) outfile = os.path.join("measurements", outfile)
if os.path.isfile(outfile): if os.path.isfile(outfile):
...@@ -158,6 +165,8 @@ def end_measurement(sal): ...@@ -158,6 +165,8 @@ def end_measurement(sal):
mdbfile = open(mdbfile, "a") mdbfile = open(mdbfile, "a")
mdbfile.write("%s > %s\n" % (' '.join(sys.argv), outfile)) mdbfile.write("%s > %s\n" % (' '.join(sys.argv), outfile))
mdbfile.close() mdbfile.close()
return 0
raise Exception("Capture didn't complete successfully")
if __name__ == "__main__": if __name__ == "__main__":
sys.exit(main(sys.argv)) sys.exit(main(sys.argv))
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