Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lwc
/
compare
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
26c47244
authored
Mar 02, 2020
by
lwc-tester
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save results as pickle - maybe too big?
parent
f4f4aedf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
58 deletions
+21
-58
test_common.py
+21
-58
No files found.
test_common.py
View file @
26c47244
...
...
@@ -5,8 +5,8 @@ import re
import
sys
import
time
import
fcntl
import
pickle
import
struct
import
serial
import
socket
import
subprocess
...
...
@@ -35,6 +35,7 @@ class DeviceUnderTest:
class
DeviceUnderTestAeadUARTP
(
DeviceUnderTest
):
def
__init__
(
self
,
ser
=
None
):
self
.
ser
=
ser
self
.
firmware_path
=
None
def
prepare
(
self
):
exp_hello
=
b
"Hello, World!"
...
...
@@ -450,20 +451,27 @@ class OpenOcd:
def
run_nist_lws_aead_test
(
vectors_file
,
build_dir
,
logic_mask
=
0xffff
,
basecls
=
DeviceUnderTestAeadUARTP
):
basecls
=
DeviceUnderTestAeadUARTP
,
results_path
=
None
):
results
=
{}
kat
=
list
(
parse_nist_aead_test_vectors
(
vectors_file
))
results
[
'test_vectors'
]
=
kat
dut
=
basecls
(
build_dir
)
fw_path
=
dut
.
firmware_path
if
fw_path
is
not
None
:
with
open
(
fw_path
,
'rb'
)
as
fw_file
:
firmware
=
fw_file
.
read
()
results
[
'firmware'
]
=
(
fw_path
,
os
.
stat
(
fw_path
),
firmware
)
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
)
...
...
@@ -476,11 +484,9 @@ def run_nist_lws_aead_test(vectors_file, build_dir,
if
i
==
1
and
dump_a
is
not
None
:
dump_b
=
dut
.
dump_ram
()
results
[
'ram_dumps'
]
=
[
dump_a
,
dump_b
]
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"
)
...
...
@@ -489,55 +495,12 @@ def run_nist_lws_aead_test(vectors_file, build_dir,
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
()
results
[
'time_dips'
]
=
tool
.
capture
if
results_path
is
None
:
results_path
=
os
.
path
.
join
(
build_dir
,
'results.pickle'
)
if
results_path
is
not
False
:
with
open
(
results_path
,
'wb'
)
as
f
:
pickle
.
dump
(
results
,
f
,
pickle
.
HIGHEST_PROTOCOL
)
if
__name__
==
"__main__"
:
sys
.
exit
(
main
(
sys
.
argv
))
return
results
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment