Commit 941d12c9 by lwc-tester

new tests

parent 07235e3c
......@@ -34,15 +34,16 @@ class BluePill(DeviceUnderTestAeadUARTP):
devname = os.path.basename(self.uart_device)
self.lock = FileMutex('/var/lock/lwc-compare.%s.lock' % devname)
self.build_dir = build_dir
self.template_path = os.path.dirname(sys.argv[0])
self.firmware_path = os.path.join(
build_dir, '.pio/build/bluepill_f103c8/firmware.elf')
build_dir, 'firmware.elf')
self.ram_pattern_path = os.path.join(
build_dir, 'empty_ram.bin')
self.template_path, 'empty_ram.bin')
self.ram_dump_path = os.path.join(
build_dir, 'ram_dump.bin')
self.openocd_cfg_path = os.path.join(
build_dir, 'openocd.cfg')
self.template_path, 'openocd.cfg')
self.ocd = OpenOcd(self.openocd_cfg_path)
......@@ -102,11 +103,14 @@ class BluePill(DeviceUnderTestAeadUARTP):
def main(argv):
if len(argv) != 3:
print("Usage: test LWC_AEAD_KAT.txt build_dir")
if len(argv) != 2:
print("Usage: test build_dir")
return 1
run_nist_lws_aead_test(argv[1], argv[2], 0x0002, BluePill)
build_dir = argv[1]
kat_path = os.path.join(build_dir, 'LWC_AEAD_KAT.txt')
run_nist_lws_aead_test(kat_path, build_dir, 0x0002, BluePill)
return 0
......
......@@ -33,6 +33,10 @@ class ESP32(DeviceUnderTestAeadUARTP):
devname = os.path.basename(self.uart_device)
self.lock = FileMutex('/var/lock/lwc-compare.%s.lock' % devname)
self.build_dir = build_dir
self.template_path = os.path.dirname(sys.argv[0])
self.firmware_path = os.path.join(
build_dir, 'firmware.elf')
def reset(self):
self.ser.setDTR(False) # IO0=HIGH
......@@ -51,28 +55,58 @@ class ESP32(DeviceUnderTestAeadUARTP):
DeviceUnderTestAeadUARTP.prepare(self)
def flash(self):
pipe = subprocess.PIPE
previous_dir = os.path.abspath(os.curdir)
os.chdir(self.build_dir)
cmd = ['platformio', 'run', '-e', 'esp32dev', '--target', 'upload']
cmd.extend(['--upload-port', self.uart_device])
p = subprocess.Popen(
cmd, stdout=sys.stderr, stdin=pipe)
stdout, stderr = p.communicate("")
assert p.returncode == 0
pio_packages_path = "/home/tester/.platformio/packages/"
esptoolpy_path = os.path.join(
pio_packages_path, "tool-esptoolpy/esptool.py")
arduinoespressif32_path = os.path.join(
pio_packages_path, "framework-arduinoespressif32/")
boot_app0_path = os.path.join(
arduinoespressif32_path,
"tools/partitions/boot_app0.bin")
bootloader_path = os.path.join(
arduinoespressif32_path,
"tools/sdk/bin/bootloader_dio_80m.bin")
elfpath = os.path.abspath(self.firmware_path)
binpath = os.path.splitext(elfpath)[0] + '.bin'
partpath = os.path.join(*os.path.split(elfpath)[:-1], 'partitions.bin')
partitions = [
(0xe000, boot_app0_path),
(0x1000, bootloader_path),
(0x10000, binpath),
(0x8000, partpath)
]
cmd = ['python3', esptoolpy_path]
cmd += ['--chip', 'esp32']
cmd += ['elf2image', elfpath]
subprocess.check_call(cmd)
cmd = ['python3', esptoolpy_path]
cmd += ['--chip', 'esp32']
cmd += ['--before', 'default_reset', '--after', 'hard_reset']
cmd += ['--port', self.uart_device]
cmd += ['write_flash', '-z']
for addr, path in partitions:
cmd += ['0x%x' % addr, path]
subprocess.check_call(cmd)
eprint("Firmware flashed.")
os.chdir(previous_dir)
def dump_ram(self):
return None
def main(argv):
if len(argv) != 3:
print("Usage: test LWC_AEAD_KAT.txt build_dir")
if len(argv) != 2:
print("Usage: test build_dir")
return 1
run_nist_lws_aead_test(argv[1], argv[2], 0x0020, ESP32)
build_dir = argv[1]
kat_path = os.path.join(build_dir, 'LWC_AEAD_KAT.txt')
run_nist_lws_aead_test(kat_path, build_dir, 0x0020, ESP32)
return 0
......
......@@ -36,12 +36,15 @@ class F7(DeviceUnderTestAeadUARTP):
devname = os.path.basename(self.uart_device)
self.lock = FileMutex('/var/lock/lwc-compare.%s.lock' % devname)
self.build_dir = build_dir
self.template_path = os.path.dirname(sys.argv[0])
self.jlink = pylink.JLink()
self.jlink.open(779340002)
self.firmware_path = os.path.join(build_dir, 'build', 'f7.bin')
self.ram_pattern_path = os.path.join(build_dir, 'ram_pattern.bin')
self.firmware_path = os.path.join(
build_dir, 'f7.bin')
self.ram_pattern_path = os.path.join(
self.template_path, 'ram_pattern.bin')
def flash(self):
jlink = self.jlink
......@@ -59,11 +62,14 @@ class F7(DeviceUnderTestAeadUARTP):
def main(argv):
if len(argv) != 3:
print("Usage: test LWC_AEAD_KAT.txt build_dir")
if len(argv) != 2:
print("Usage: test build_dir")
return 1
run_nist_lws_aead_test(argv[1], argv[2], 0x0008, F7)
build_dir = argv[1]
kat_path = os.path.join(build_dir, 'LWC_AEAD_KAT.txt')
run_nist_lws_aead_test(kat_path, build_dir, 0x0008, F7)
return 0
......
......@@ -34,8 +34,19 @@ class Maixduino(DeviceUnderTestAeadUARTP):
devname = os.path.basename(self.uart_device)
self.lock = FileMutex('/var/lock/lwc-compare.%s.lock' % devname)
self.build_dir = build_dir
self.template_path = os.path.dirname(sys.argv[0])
self.firmware_path = os.path.join(
build_dir, 'firmware.bin')
def reset(self):
if self.ser is not None:
self.ser.close()
self.ser = serial.Serial(
self.uart_device,
baudrate=1500000,
timeout=5)
self.ser.setRTS(True)
time.sleep(0.1)
self.ser.setRTS(False)
......@@ -44,37 +55,37 @@ class Maixduino(DeviceUnderTestAeadUARTP):
time.sleep(1)
def prepare(self):
self.ser = serial.Serial(
self.uart_device,
baudrate=1500000,
timeout=5)
self.reset()
self.reset()
DeviceUnderTestAeadUARTP.prepare(self)
def flash(self):
pipe = subprocess.PIPE
previous_dir = os.path.abspath(os.curdir)
os.chdir(self.build_dir)
cmd = ['platformio', 'run', '-e', 'sipeed-maixduino']
cmd.extend(['--target', 'upload'])
cmd.extend(['--upload-port', self.uart_device])
p = subprocess.Popen(
cmd, stdout=sys.stderr, stdin=pipe)
stdout, stderr = p.communicate("")
assert p.returncode == 0
pio_packages_path = "/home/tester/.platformio/packages/"
kflash_path = os.path.join(
pio_packages_path, "tool-kflash-kendryte210/kflash.py")
cmd = ['python3', kflash_path]
cmd += ['-b', '750000']
cmd += ['-p', self.uart_device]
cmd += ['-B', 'maixduino']
cmd += [self.firmware_path]
subprocess.check_call(cmd)
eprint("Firmware flashed.")
os.chdir(previous_dir)
def dump_ram(self):
return None
def main(argv):
if len(argv) != 3:
print("Usage: test LWC_AEAD_KAT.txt build_dir")
if len(argv) != 2:
print("Usage: test build_dir")
return 1
run_nist_lws_aead_test(argv[1], argv[2], 0x0080, Maixduino)
build_dir = argv[1]
kat_path = os.path.join(build_dir, 'LWC_AEAD_KAT.txt')
run_nist_lws_aead_test(kat_path, build_dir, 0x0080, Maixduino)
return 0
......
......@@ -33,6 +33,10 @@ class Uno(DeviceUnderTestAeadUARTP):
devname = os.path.basename(self.uart_device)
self.lock = FileMutex('/var/lock/lwc-compare.%s.lock' % devname)
self.build_dir = build_dir
self.template_path = os.path.dirname(sys.argv[0])
self.firmware_path = os.path.join(
build_dir, 'firmware.hex')
def reset(self):
self.ser.setDTR(True)
......@@ -50,27 +54,46 @@ class Uno(DeviceUnderTestAeadUARTP):
def flash(self):
pipe = subprocess.PIPE
previous_dir = os.path.abspath(os.curdir)
os.chdir(self.build_dir)
cmd = ['platformio', 'run', '-e', 'uno', '--target', 'upload']
cmd.extend(['--upload-port', self.uart_device])
avrdude_dir = '/home/tester/.platformio/packages/tool-avrdude/'
cmd = [os.path.join(avrdude_dir, 'avrdude')]
cmd += ['-C', os.path.join(avrdude_dir, 'avrdude.conf')]
cmd += ['-v']
cmd += ['-p', 'atmega328p']
cmd += ['-c', 'arduino']
cmd += ['-P', self.uart_device]
cmd += ['-b', '115200']
cmd += ['-D']
cmd += ['-U', 'flash:w:%s:i' % os.path.abspath(self.firmware_path)]
self.ser = serial.Serial(
self.uart_device,
baudrate=115200,
timeout=5)
self.ser.setDTR(True)
time.sleep(0.01)
self.ser.setDTR(False)
self.ser.close()
p = subprocess.Popen(
cmd, stdout=sys.stderr, stdin=pipe)
stdout, stderr = p.communicate("")
assert p.returncode == 0
eprint("Firmware flashed.")
os.chdir(previous_dir)
def dump_ram(self):
return None
def main(argv):
if len(argv) != 3:
print("Usage: test LWC_AEAD_KAT.txt build_dir")
if len(argv) != 2:
print("Usage: test build_dir")
return 1
run_nist_lws_aead_test(argv[1], argv[2], 0x0800, Uno)
build_dir = argv[1]
kat_path = os.path.join(build_dir, 'LWC_AEAD_KAT.txt')
run_nist_lws_aead_test(kat_path, build_dir, 0x0800, Uno)
return 0
......
......@@ -473,8 +473,8 @@ def run_nist_lws_aead_test(vectors_file, build_dir,
dump_a = dut.dump_ram()
tool = LogicMultiplexerTimeMeasurements(logic_mask)
try:
tool = LogicMultiplexerTimeMeasurements(logic_mask)
tool.begin_measurement()
for i, m, ad, k, npub, c in kat:
......
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