blob: a6794d69b527d880bc010286c864214e02585b94 [file] [log] [blame]
Marti Bolivar38d67f72017-11-14 20:22:03 -05001#!/bin/bash
2
3# Test runner
4#
5# Copyright (c) 2017 Open Source Foundries Limited
6
7#
8# This script can be used to execute the Zephyr test plan detailed in
9# docs/testplan-zephyr.md.
10#
11
12function ok_yn () {
13 while true ; do
14 read -p "Test result OK (y/n)? " -n 1 choice
15 echo
16 case "$choice" in
17 y|Y )
18 return
19 ;;
20 n|N )
21 echo "Test failed; exiting"
22 exit 1
23 ;;
24 * )
25 echo Please enter y or n
26 ;;
27 esac
28 done
29}
30
31set -e
32
33echo '--------------------------------------------------------'
34echo '------------------------ GOOD RSA ----------------------'
35make test-good-rsa
36pyocd-flashtool -ce
37echo "Flashing bootloader"
38make flash_boot
39echo "Expected result: unable to find bootable image"
40ok_yn
41echo "Flashing hello 1"
42make flash_hello1
43echo "Expected result: hello1 runs"
44ok_yn
45echo "Flashing hello 2"
46make flash_hello2
47echo "Expected result: hello2 runs"
48ok_yn
49echo "Resetting"
50pyocd-tool reset
51echo "Expected result: hello1 runs"
52ok_yn
53
54echo '--------------------------------------------------------'
55echo '------------------------ GOOD ECDSA --------------------'
56make test-good-ecdsa
57pyocd-flashtool -ce
58make flash_boot
59echo "Expected result: unable to find bootable image"
60ok_yn
61echo "Flashing hello 1"
62make flash_hello1
63echo "Expected result: hello1 runs"
64ok_yn
65echo "Flashing hello 2"
66make flash_hello2
67echo "Expected result: hello2 runs"
68ok_yn
69echo "Resetting"
70pyocd-tool reset
71echo "Expected result: hello1 runs"
72ok_yn
73
74echo '--------------------------------------------------------'
75echo '------------------------ OVERWRITE ---------------------'
76make test-overwrite
77pyocd-flashtool -ce
78make flash_boot
79echo "Expected result: unable to find bootable image"
80ok_yn
81echo "Flashing hello 1"
82make flash_hello1
83echo "Expected result: hello1 runs"
84ok_yn
85echo "Flashing hello 2"
86make flash_hello2
87echo "Expected result: hello2 runs"
88ok_yn
89echo "Resetting"
90pyocd-tool reset
91echo "Expected result: hello2 runs"
92ok_yn
93
94echo '--------------------------------------------------------'
95echo '------------------------ BAD RSA -----------------------'
96make test-bad-rsa-upgrade
97pyocd-flashtool -ce
98make flash_boot
99echo "Expected result: unable to find bootable image"
100ok_yn
101echo "Flashing hello 1"
102make flash_hello1
103echo "Expected result: hello1 runs"
104ok_yn
105echo "Flashing hello 2"
106make flash_hello2
107echo "Expected result: hello1 runs"
108ok_yn
109echo "Resetting"
110pyocd-tool reset
111echo "Expected result: hello1 runs"
112ok_yn
113
114echo '--------------------------------------------------------'
115echo '------------------------ BAD ECDSA ---------------------'
116make test-bad-ecdsa-upgrade
117pyocd-flashtool -ce
118make flash_boot
119echo "Expected result: unable to find bootable image"
120ok_yn
121echo "Flashing hello 1"
122make flash_hello1
123echo "Expected result: hello1 runs"
124ok_yn
125echo "Flashing hello 2"
126make flash_hello2
127echo "Expected result: hello1 runs"
128ok_yn
129echo "Resetting"
130pyocd-tool reset
131echo "Expected result: hello1 runs"
132ok_yn
133
134echo '--------------------------------------------------------'
135echo '------------------------ NO BOOTCHECK ------------------'
136make test-no-bootcheck
137pyocd-flashtool -ce
138make flash_boot
139echo "Expected result: unable to find bootable image"
140ok_yn
141echo "Flashing hello 1"
142make flash_hello1
143echo "Expected result: hello1 runs"
144ok_yn
145echo "Flashing hello 2"
146make flash_hello2
147echo "Expected result: hello1 runs"
148ok_yn
149echo "Resetting"
150pyocd-tool reset
151echo "Expected result: hello1 runs"
152ok_yn
153
154echo '--------------------------------------------------------'
155echo '------------------------ WRONG RSA ---------------------'
156make test-wrong-rsa
157pyocd-flashtool -ce
158make flash_boot
159echo "Expected result: unable to find bootable image"
160ok_yn
161echo "Flashing hello 1"
162make flash_hello1
163echo "Expected result: hello1 runs"
164ok_yn
165echo "Flashing hello 2"
166make flash_hello2
167echo "Expected result: hello1 runs"
168ok_yn
169echo "Resetting"
170pyocd-tool reset
171echo "Expected result: hello1 runs"
172ok_yn
173
174echo '--------------------------------------------------------'
175echo '------------------------ WRONG ECDSA -------------------'
176make test-wrong-ecdsa
177pyocd-flashtool -ce
178make flash_boot
179echo "Expected result: unable to find bootable image"
180ok_yn
181echo "Flashing hello 1"
182make flash_hello1
183echo "Expected result: hello1 runs"
184ok_yn
185echo "Flashing hello 2"
186make flash_hello2
187echo "Expected result: hello1 runs"
188ok_yn
189echo "Resetting"
190pyocd-tool reset
191echo "Expected result: hello1 runs"
192ok_yn
193
194echo '========================================================'
195echo ' ALL TESTS PASSED'
196echo '========================================================'