-
Notifications
You must be signed in to change notification settings - Fork 15
/
test_headless.sh
82 lines (61 loc) · 1.18 KB
/
test_headless.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
function error {
echo "error: $1"
exit 1
}
function usage {
echo "usage: $0 [-h] [-m|--model (nanos|nanox)]"
exit 1
}
# default
device="nanos"
realpath="$( dirname $( readlink -f $0 ) )"
FLAGS=""
while (($# > 0))
do
case "$1" in
"-h" | "--help")
usage
;;
"-m" | "--model")
shift
device="$1"
;;
*)
error "unknown parameter"
;;
esac
shift
done
[[ "$device" != "nanos" && "$device" != "nanox" ]] && {
error "unknown device"
}
[[ "$device" == "nanos" ]] && {
sdk="2.0"
}
[[ "$device" == "nanox" ]] && {
sdk="1.2"
}
echo "device $device selected"
cd $realpath
# recompile the app
cd ..
source env_${device}.sh
make clean
SPECULOS=1 make
# start speculos in headless mode in the background
cd ./dev/speculos
python3.8 speculos.py --sdk $sdk --display headless -m ${device} ../../bin/app.elf &>/dev/null &
speculos_pid=$!
cd -
# wait for speculos to be ready
sleep 10
#netstat -nlp
# now compile test code and run test
cd tests
gcc tests.c -o tests
./tests reference_${device}.bin || error "testing failed for $device"
# kill speculos
kill $speculos_pid
cd -
exit 0