blob: e2e4a9caa0890bff5214573f4eb487bb597eefe3 [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
Maureen Helm0e0c4882019-02-18 17:20:00 -060036pyocd erase --chip
Marti Bolivar38d67f72017-11-14 20:22:03 -050037echo "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"
Maureen Helm0e0c4882019-02-18 17:20:00 -060050pyocd commander -c reset
Marti Bolivar38d67f72017-11-14 20:22:03 -050051echo "Expected result: hello1 runs"
52ok_yn
53
54echo '--------------------------------------------------------'
55echo '------------------------ GOOD ECDSA --------------------'
56make test-good-ecdsa
Maureen Helm0e0c4882019-02-18 17:20:00 -060057pyocd erase --chip
Marti Bolivar38d67f72017-11-14 20:22:03 -050058make 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"
Maureen Helm0e0c4882019-02-18 17:20:00 -060070pyocd commander -c reset
Marti Bolivar38d67f72017-11-14 20:22:03 -050071echo "Expected result: hello1 runs"
72ok_yn
73
74echo '--------------------------------------------------------'
75echo '------------------------ OVERWRITE ---------------------'
76make test-overwrite
Maureen Helm0e0c4882019-02-18 17:20:00 -060077pyocd erase --chip
Marti Bolivar38d67f72017-11-14 20:22:03 -050078make 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"
Maureen Helm0e0c4882019-02-18 17:20:00 -060090pyocd commander -c reset
Marti Bolivar38d67f72017-11-14 20:22:03 -050091echo "Expected result: hello2 runs"
92ok_yn
93
94echo '--------------------------------------------------------'
95echo '------------------------ BAD RSA -----------------------'
96make test-bad-rsa-upgrade
Maureen Helm0e0c4882019-02-18 17:20:00 -060097pyocd erase --chip
Marti Bolivar38d67f72017-11-14 20:22:03 -050098make 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"
Maureen Helm0e0c4882019-02-18 17:20:00 -0600110pyocd commander -c reset
Marti Bolivar38d67f72017-11-14 20:22:03 -0500111echo "Expected result: hello1 runs"
112ok_yn
113
114echo '--------------------------------------------------------'
115echo '------------------------ BAD ECDSA ---------------------'
116make test-bad-ecdsa-upgrade
Maureen Helm0e0c4882019-02-18 17:20:00 -0600117pyocd erase --chip
Marti Bolivar38d67f72017-11-14 20:22:03 -0500118make 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"
Maureen Helm0e0c4882019-02-18 17:20:00 -0600130pyocd commander -c reset
Marti Bolivar38d67f72017-11-14 20:22:03 -0500131echo "Expected result: hello1 runs"
132ok_yn
133
134echo '--------------------------------------------------------'
135echo '------------------------ NO BOOTCHECK ------------------'
136make test-no-bootcheck
Maureen Helm0e0c4882019-02-18 17:20:00 -0600137pyocd erase --chip
Marti Bolivar38d67f72017-11-14 20:22:03 -0500138make 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"
Maureen Helm0e0c4882019-02-18 17:20:00 -0600150pyocd commander -c reset
Marti Bolivar38d67f72017-11-14 20:22:03 -0500151echo "Expected result: hello1 runs"
152ok_yn
153
154echo '--------------------------------------------------------'
155echo '------------------------ WRONG RSA ---------------------'
156make test-wrong-rsa
Maureen Helm0e0c4882019-02-18 17:20:00 -0600157pyocd erase --chip
Marti Bolivar38d67f72017-11-14 20:22:03 -0500158make 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"
Maureen Helm0e0c4882019-02-18 17:20:00 -0600170pyocd commander -c reset
Marti Bolivar38d67f72017-11-14 20:22:03 -0500171echo "Expected result: hello1 runs"
172ok_yn
173
174echo '--------------------------------------------------------'
175echo '------------------------ WRONG ECDSA -------------------'
176make test-wrong-ecdsa
Maureen Helm0e0c4882019-02-18 17:20:00 -0600177pyocd erase --chip
Marti Bolivar38d67f72017-11-14 20:22:03 -0500178make 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"
Maureen Helm0e0c4882019-02-18 17:20:00 -0600190pyocd commander -c reset
Marti Bolivar38d67f72017-11-14 20:22:03 -0500191echo "Expected result: hello1 runs"
192ok_yn
193
194echo '========================================================'
195echo ' ALL TESTS PASSED'
196echo '========================================================'