1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-24 23:38:09 +00:00

tests: implement otp read/write in production test

This commit is contained in:
Pavol Rusnak 2017-09-27 13:32:55 +02:00
parent 67d8d4fa2e
commit 737dc0159f
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -25,6 +25,7 @@ usb.add(usb_vcp)
usb.open() usb.open()
d = ui.Display() d = ui.Display()
otp = io.FlashOTP()
sd = io.SDCard() sd = io.SDCard()
sbu = io.SBU() sbu = io.SBU()
@ -112,14 +113,19 @@ def test_sbu(v):
print('OK') print('OK')
def test_otp_read(v): def test_otp_read():
# FIXME: really read data = bytearray(32)
otp = '00000' otp.read(0, 0, data)
print('OK', otp) data = bytes(data).rstrip(b'\x00\xff').decode()
print('OK', data)
def test_otp_write(v): def test_otp_write(v):
# FIXME: really write if len(v) < 32:
v = v + '\x00' * (32 - len(v))
data = v[:32].encode()
otp.write(0, 0, data)
otp.lock(0)
print('OK') print('OK')
@ -147,7 +153,7 @@ while True:
test_sbu(line[4:]) test_sbu(line[4:])
elif line.startswith('OTP READ'): elif line.startswith('OTP READ'):
test_otp_read(line[8:]) test_otp_read()
elif line.startswith('OTP WRITE '): elif line.startswith('OTP WRITE '):
test_otp_write(line[10:]) test_otp_write(line[10:])