Commit 941d12c9 by lwc-tester

new tests

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