Commit f4f4aedf by lwc-tester

this should be ready

parent 8686290f
...@@ -4,14 +4,11 @@ import os ...@@ -4,14 +4,11 @@ import os
import sys import sys
import serial.tools.list_ports import serial.tools.list_ports
from test_common import ( from test_common import (
LogicMultiplexerTimeMeasurements,
parse_nist_aead_test_vectors,
DeviceUnderTestAeadUARTP, DeviceUnderTestAeadUARTP,
compare_dumps,
eprint, eprint,
OpenOcd, OpenOcd,
FileMutex, FileMutex,
run_nist_aead_test_line, run_nist_lws_aead_test
) )
...@@ -109,38 +106,8 @@ def main(argv): ...@@ -109,38 +106,8 @@ def main(argv):
print("Usage: test LWC_AEAD_KAT.txt build_dir") print("Usage: test LWC_AEAD_KAT.txt build_dir")
return 1 return 1
kat = list(parse_nist_aead_test_vectors(argv[1])) run_nist_lws_aead_test(argv[1], argv[2], 0x0002, BluePill)
build_dir = argv[2] return 0
dut = BluePill(build_dir)
dut.flash()
dut.prepare()
sys.stdout.write("Board prepared\n")
sys.stdout.flush()
dump_a = dut.dump_ram()
try:
tool = LogicMultiplexerTimeMeasurements(0x0002)
tool.begin_measurement()
for i, m, ad, k, npub, c in kat:
tool.arm()
run_nist_aead_test_line(dut, i, m, ad, k, npub, c)
tool.unarm()
if i == 1 and dump_a is not None:
dump_b = dut.dump_ram()
longest = compare_dumps(dump_a, dump_b)
print(" longest chunk of untouched memory = %d" % longest)
except Exception as ex:
print("TEST FAILED")
raise ex
finally:
tool.end_measurement()
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -6,12 +6,10 @@ import time ...@@ -6,12 +6,10 @@ import time
import subprocess import subprocess
import serial.tools.list_ports import serial.tools.list_ports
from test_common import ( from test_common import (
LogicMultiplexerTimeMeasurements,
parse_nist_aead_test_vectors,
DeviceUnderTestAeadUARTP, DeviceUnderTestAeadUARTP,
eprint, eprint,
FileMutex, FileMutex,
run_nist_aead_test_line, run_nist_lws_aead_test,
) )
...@@ -74,30 +72,8 @@ def main(argv): ...@@ -74,30 +72,8 @@ def main(argv):
print("Usage: test LWC_AEAD_KAT.txt build_dir") print("Usage: test LWC_AEAD_KAT.txt build_dir")
return 1 return 1
kat = list(parse_nist_aead_test_vectors(argv[1])) run_nist_lws_aead_test(argv[1], argv[2], 0x0020, ESP32)
build_dir = argv[2] return 0
dut = ESP32(build_dir)
dut.flash()
dut.prepare()
sys.stdout.write("Board prepared\n")
sys.stdout.flush()
try:
tool = LogicMultiplexerTimeMeasurements(0x0020)
tool.begin_measurement()
for i, m, ad, k, npub, c in kat:
tool.arm()
run_nist_aead_test_line(dut, i, m, ad, k, npub, c)
tool.unarm()
except Exception as ex:
print("TEST FAILED")
raise ex
finally:
tool.end_measurement()
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -5,13 +5,10 @@ import sys ...@@ -5,13 +5,10 @@ import sys
import pylink import pylink
import serial.tools.list_ports import serial.tools.list_ports
from test_common import ( from test_common import (
LogicMultiplexerTimeMeasurements,
parse_nist_aead_test_vectors,
DeviceUnderTestAeadUARTP, DeviceUnderTestAeadUARTP,
compare_dumps,
eprint, eprint,
FileMutex, FileMutex,
run_nist_aead_test_line, run_nist_lws_aead_test,
) )
...@@ -66,38 +63,8 @@ def main(argv): ...@@ -66,38 +63,8 @@ def main(argv):
print("Usage: test LWC_AEAD_KAT.txt build_dir") print("Usage: test LWC_AEAD_KAT.txt build_dir")
return 1 return 1
kat = list(parse_nist_aead_test_vectors(argv[1])) run_nist_lws_aead_test(argv[1], argv[2], 0x0008, F7)
build_dir = argv[2] return 0
dut = F7(build_dir)
dut.flash()
dut.prepare()
sys.stdout.write("Board prepared\n")
sys.stdout.flush()
dump_a = dut.dump_ram()
try:
tool = LogicMultiplexerTimeMeasurements(0x0008)
tool.begin_measurement()
for i, m, ad, k, npub, c in kat:
tool.arm()
run_nist_aead_test_line(dut, i, m, ad, k, npub, c)
tool.unarm()
if i == 1:
dump_b = dut.dump_ram()
longest = compare_dumps(dump_a, dump_b)
print(" longest chunk of untouched memory = %d" % longest)
except Exception as ex:
print("TEST FAILED")
raise ex
finally:
tool.end_measurement()
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -6,12 +6,10 @@ import time ...@@ -6,12 +6,10 @@ import time
import subprocess import subprocess
import serial.tools.list_ports import serial.tools.list_ports
from test_common import ( from test_common import (
LogicMultiplexerTimeMeasurements,
parse_nist_aead_test_vectors,
DeviceUnderTestAeadUARTP, DeviceUnderTestAeadUARTP,
FileMutex, FileMutex,
eprint, eprint,
run_nist_aead_test_line, run_nist_lws_aead_test,
) )
...@@ -76,30 +74,8 @@ def main(argv): ...@@ -76,30 +74,8 @@ def main(argv):
print("Usage: test LWC_AEAD_KAT.txt build_dir") print("Usage: test LWC_AEAD_KAT.txt build_dir")
return 1 return 1
kat = list(parse_nist_aead_test_vectors(argv[1])) run_nist_lws_aead_test(argv[1], argv[2], 0x0080, Maixduino)
build_dir = argv[2] return 0
dut = Maixduino(build_dir)
dut.flash()
dut.prepare()
sys.stdout.write("Board prepared\n")
sys.stdout.flush()
try:
tool = LogicMultiplexerTimeMeasurements(0x0080)
tool.begin_measurement()
for i, m, ad, k, npub, c in kat:
tool.arm()
run_nist_aead_test_line(dut, i, m, ad, k, npub, c)
tool.unarm()
except Exception as ex:
print("TEST FAILED")
raise ex
finally:
tool.end_measurement()
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -6,12 +6,10 @@ import time ...@@ -6,12 +6,10 @@ import time
import subprocess import subprocess
import serial.tools.list_ports import serial.tools.list_ports
from test_common import ( from test_common import (
LogicMultiplexerTimeMeasurements,
parse_nist_aead_test_vectors,
DeviceUnderTestAeadUARTP, DeviceUnderTestAeadUARTP,
eprint, eprint,
FileMutex, FileMutex,
run_nist_aead_test_line, run_nist_lws_aead_test,
) )
...@@ -72,31 +70,8 @@ def main(argv): ...@@ -72,31 +70,8 @@ def main(argv):
print("Usage: test LWC_AEAD_KAT.txt build_dir") print("Usage: test LWC_AEAD_KAT.txt build_dir")
return 1 return 1
kat = list(parse_nist_aead_test_vectors(argv[1])) run_nist_lws_aead_test(argv[1], argv[2], 0x0800, Uno)
build_dir = argv[2] return 0
dut = Uno(build_dir)
dut.flash()
dut.prepare()
sys.stdout.write("Board prepared\n")
sys.stdout.flush()
try:
tool = LogicMultiplexerTimeMeasurements(0x0800)
tool.begin_measurement()
for i, m, ad, k, npub, c in kat:
tool.arm()
run_nist_aead_test_line(dut, i, m, ad, k, npub, c)
tool.unarm()
except Exception as ex:
print("TEST FAILED")
raise ex
finally:
tool.end_measurement()
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -368,53 +368,6 @@ class SaleaeTimeMeasurements(TimeMeasurementTool): ...@@ -368,53 +368,6 @@ class SaleaeTimeMeasurements(TimeMeasurementTool):
raise Exception("Capture didn't complete successfully") raise Exception("Capture didn't complete successfully")
def main(argv):
if len(argv) < 3:
print("Usage: test_common.py port LWC_AEAD_KAT.txt")
eprint(argv[0])
script_dir = os.path.split(argv[0])[0]
if len(script_dir) > 0:
os.chdir(script_dir)
kat = list(parse_nist_aead_test_vectors(argv[2]))
dev = argv[1]
ser = serial.Serial(dev, baudrate=115200, timeout=5)
dut = DeviceUnderTestAeadUARTP(ser)
try:
tool = SaleaeTimeMeasurements()
tool.begin_measurement()
dut.flash()
eprint("Flashed")
dut.prepare()
eprint("Prepared")
sys.stdout.write("Hello, World!\n")
sys.stdout.flush()
dump_a = dut.dump_ram()
for i, m, ad, k, npub, c in kat:
tool.arm()
run_nist_aead_test_line(dut, i, m, ad, k, npub, c)
tool.unarm()
if dump_a is not None and i == 1:
dump_b = dut.dump_ram()
longest = compare_dumps(dump_a, dump_b)
print(" longest chunk of untouched memory = %d" % longest)
except Exception as ex:
print("TEST FAILED")
raise ex
finally:
tool.end_measurement()
sys.stdout.flush()
sys.stderr.flush()
class FileMutex: class FileMutex:
def __init__(self, lock_path): def __init__(self, lock_path):
self.lock_path = lock_path self.lock_path = lock_path
...@@ -495,5 +448,96 @@ class OpenOcd: ...@@ -495,5 +448,96 @@ class OpenOcd:
return data.decode('ascii') return data.decode('ascii')
def run_nist_lws_aead_test(vectors_file, build_dir,
logic_mask=0xffff,
basecls=DeviceUnderTestAeadUARTP):
kat = list(parse_nist_aead_test_vectors(vectors_file))
dut = basecls(build_dir)
dut.flash()
dut.prepare()
sys.stdout.write("Board prepared\n")
sys.stdout.flush()
dump_a = dut.dump_ram()
time_dips = None
ram_utilization = None
rom_utilization = None
try:
tool = LogicMultiplexerTimeMeasurements(logic_mask)
tool.begin_measurement()
for i, m, ad, k, npub, c in kat:
tool.arm()
run_nist_aead_test_line(dut, i, m, ad, k, npub, c)
tool.unarm()
if i == 1 and dump_a is not None:
dump_b = dut.dump_ram()
longest = compare_dumps(dump_a, dump_b)
print(" longest chunk of untouched memory = %d" % longest)
ram_utilization = longest
time_dips = tool.capture
except Exception as ex:
print("TEST FAILED")
raise ex
finally:
tool.end_measurement()
return time_dips, ram_utilization, rom_utilization
def main(argv):
if len(argv) < 3:
print("Usage: test_common.py port LWC_AEAD_KAT.txt")
eprint(argv[0])
script_dir = os.path.split(argv[0])[0]
if len(script_dir) > 0:
os.chdir(script_dir)
kat = list(parse_nist_aead_test_vectors(argv[2]))
dev = argv[1]
ser = serial.Serial(dev, baudrate=115200, timeout=5)
dut = DeviceUnderTestAeadUARTP(ser)
try:
tool = SaleaeTimeMeasurements()
tool.begin_measurement()
dut.flash()
eprint("Flashed")
dut.prepare()
eprint("Prepared")
sys.stdout.write("Hello, World!\n")
sys.stdout.flush()
dump_a = dut.dump_ram()
for i, m, ad, k, npub, c in kat:
tool.arm()
run_nist_aead_test_line(dut, i, m, ad, k, npub, c)
tool.unarm()
if dump_a is not None and i == 1:
dump_b = dut.dump_ram()
longest = compare_dumps(dump_a, dump_b)
print(" longest chunk of untouched memory = %d" % longest)
except Exception as ex:
print("TEST FAILED")
raise ex
finally:
tool.end_measurement()
sys.stdout.flush()
sys.stderr.flush()
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