blob: e250f98d23ef94c1809be6096e8494417b3b81e0 [file] [log] [blame]
David Brown5e8dbb92020-09-09 13:17:38 -06001// Package mcutests
Fabio Utzigde1d72d2020-11-10 12:35:04 -03002package mcutests // github.com/mcu-tools/mcuboot/samples/zephyr/mcutests
David Brown5e8dbb92020-09-09 13:17:38 -06003
4// The main driver of this consists of a series of tests. Each test
5// then contains a series of commands and expect results.
6var Tests = []struct {
David Brownc997a602020-09-09 17:06:21 -06007 Name string
8 ShortName string
9 Tests []OneTest
David Brown5e8dbb92020-09-09 13:17:38 -060010}{
11 {
David Brownc997a602020-09-09 17:06:21 -060012 Name: "Good RSA",
13 ShortName: "good-rsa",
David Brown5e8dbb92020-09-09 13:17:38 -060014 Tests: []OneTest{
15 {
David Brownf15a0102020-09-10 08:25:53 -060016 Build: [][]string{
David Brown5e8dbb92020-09-09 13:17:38 -060017 {"make", "test-good-rsa"},
David Brownf15a0102020-09-10 08:25:53 -060018 },
19 Commands: [][]string{
David Brown5e8dbb92020-09-09 13:17:38 -060020 {"make", "flash_boot"},
21 },
22 Expect: "Unable to find bootable image",
23 },
24 {
25 Commands: [][]string{
26 {"make", "flash_hello1"},
27 },
28 Expect: "Hello World from hello1",
29 },
30 {
31 Commands: [][]string{
32 {"make", "flash_hello2"},
33 },
34 Expect: "Hello World from hello2",
35 },
36 {
37 Commands: [][]string{
38 {"pyocd", "commander", "-c", "reset"},
39 },
40 Expect: "Hello World from hello1",
41 },
42 },
43 },
44 {
David Brownc997a602020-09-09 17:06:21 -060045 Name: "Good ECDSA",
46 ShortName: "good-ecdsa",
David Brown5e8dbb92020-09-09 13:17:38 -060047 Tests: []OneTest{
48 {
David Brownf15a0102020-09-10 08:25:53 -060049 Build: [][]string{
David Brown5e8dbb92020-09-09 13:17:38 -060050 {"make", "test-good-ecdsa"},
David Brownf15a0102020-09-10 08:25:53 -060051 },
52 Commands: [][]string{
David Brown5e8dbb92020-09-09 13:17:38 -060053 {"make", "flash_boot"},
54 },
55 Expect: "Unable to find bootable image",
56 },
57 {
58 Commands: [][]string{
59 {"make", "flash_hello1"},
60 },
61 Expect: "Hello World from hello1",
62 },
63 {
64 Commands: [][]string{
65 {"make", "flash_hello2"},
66 },
67 Expect: "Hello World from hello2",
68 },
69 {
70 Commands: [][]string{
71 {"pyocd", "commander", "-c", "reset"},
72 },
73 Expect: "Hello World from hello1",
74 },
75 },
76 },
77 {
David Brownc997a602020-09-09 17:06:21 -060078 Name: "Overwrite",
79 ShortName: "overwrite",
David Brown5e8dbb92020-09-09 13:17:38 -060080 Tests: []OneTest{
81 {
David Brownf15a0102020-09-10 08:25:53 -060082 Build: [][]string{
David Brown5e8dbb92020-09-09 13:17:38 -060083 {"make", "test-overwrite"},
David Brownf15a0102020-09-10 08:25:53 -060084 },
85 Commands: [][]string{
David Brown5e8dbb92020-09-09 13:17:38 -060086 {"make", "flash_boot"},
87 },
88 Expect: "Unable to find bootable image",
89 },
90 {
91 Commands: [][]string{
92 {"make", "flash_hello1"},
93 },
94 Expect: "Hello World from hello1",
95 },
96 {
97 Commands: [][]string{
98 {"make", "flash_hello2"},
99 },
100 Expect: "Hello World from hello2",
101 },
102 {
103 Commands: [][]string{
104 {"pyocd", "commander", "-c", "reset"},
105 },
106 Expect: "Hello World from hello2",
107 },
108 },
109 },
110 {
David Brownc997a602020-09-09 17:06:21 -0600111 Name: "Bad RSA",
112 ShortName: "bad-rsa-upgrade",
David Brown5e8dbb92020-09-09 13:17:38 -0600113 Tests: []OneTest{
114 {
David Brownf15a0102020-09-10 08:25:53 -0600115 Build: [][]string{
David Brown5e8dbb92020-09-09 13:17:38 -0600116 {"make", "test-bad-rsa-upgrade"},
David Brownf15a0102020-09-10 08:25:53 -0600117 },
118 Commands: [][]string{
David Brown5e8dbb92020-09-09 13:17:38 -0600119 {"make", "flash_boot"},
120 },
121 Expect: "Unable to find bootable image",
122 },
123 {
124 Commands: [][]string{
125 {"make", "flash_hello1"},
126 },
127 Expect: "Hello World from hello1",
128 },
129 {
130 Commands: [][]string{
131 {"make", "flash_hello2"},
132 },
133 Expect: "Hello World from hello1",
134 },
135 {
136 Commands: [][]string{
137 {"pyocd", "commander", "-c", "reset"},
138 },
139 Expect: "Hello World from hello1",
140 },
141 },
142 },
143 {
David Brownc997a602020-09-09 17:06:21 -0600144 Name: "Bad RSA",
145 ShortName: "bad-ecdsa-upgrade",
David Brown5e8dbb92020-09-09 13:17:38 -0600146 Tests: []OneTest{
147 {
David Brownf15a0102020-09-10 08:25:53 -0600148 Build: [][]string{
David Brown5e8dbb92020-09-09 13:17:38 -0600149 {"make", "test-bad-ecdsa-upgrade"},
David Brownf15a0102020-09-10 08:25:53 -0600150 },
151 Commands: [][]string{
David Brown5e8dbb92020-09-09 13:17:38 -0600152 {"make", "flash_boot"},
153 },
154 Expect: "Unable to find bootable image",
155 },
156 {
157 Commands: [][]string{
158 {"make", "flash_hello1"},
159 },
160 Expect: "Hello World from hello1",
161 },
162 {
163 Commands: [][]string{
164 {"make", "flash_hello2"},
165 },
166 Expect: "Hello World from hello1",
167 },
168 {
169 Commands: [][]string{
170 {"pyocd", "commander", "-c", "reset"},
171 },
172 Expect: "Hello World from hello1",
173 },
174 },
175 },
176 {
David Brownc997a602020-09-09 17:06:21 -0600177 Name: "No bootcheck",
178 ShortName: "no-bootcheck",
David Brown5e8dbb92020-09-09 13:17:38 -0600179 Tests: []OneTest{
180 {
David Brownf15a0102020-09-10 08:25:53 -0600181 Build: [][]string{
David Brown5e8dbb92020-09-09 13:17:38 -0600182 {"make", "test-no-bootcheck"},
David Brownf15a0102020-09-10 08:25:53 -0600183 },
184 Commands: [][]string{
David Brown5e8dbb92020-09-09 13:17:38 -0600185 {"make", "flash_boot"},
186 },
187 Expect: "Unable to find bootable image",
188 },
189 {
190 Commands: [][]string{
191 {"make", "flash_hello1"},
192 },
193 Expect: "Hello World from hello1",
194 },
195 {
196 Commands: [][]string{
197 {"make", "flash_hello2"},
198 },
199 Expect: "Hello World from hello1",
200 },
201 {
202 Commands: [][]string{
203 {"pyocd", "commander", "-c", "reset"},
204 },
205 Expect: "Hello World from hello1",
206 },
207 },
208 },
209 {
David Brownc997a602020-09-09 17:06:21 -0600210 Name: "Wrong RSA",
211 ShortName: "wrong-rsa",
David Brown5e8dbb92020-09-09 13:17:38 -0600212 Tests: []OneTest{
213 {
David Brownf15a0102020-09-10 08:25:53 -0600214 Build: [][]string{
David Brown5e8dbb92020-09-09 13:17:38 -0600215 {"make", "test-wrong-rsa"},
David Brownf15a0102020-09-10 08:25:53 -0600216 },
217 Commands: [][]string{
David Brown5e8dbb92020-09-09 13:17:38 -0600218 {"make", "flash_boot"},
219 },
220 Expect: "Unable to find bootable image",
221 },
222 {
223 Commands: [][]string{
224 {"make", "flash_hello1"},
225 },
226 Expect: "Hello World from hello1",
227 },
228 {
229 Commands: [][]string{
230 {"make", "flash_hello2"},
231 },
232 Expect: "Hello World from hello1",
233 },
234 {
235 Commands: [][]string{
236 {"pyocd", "commander", "-c", "reset"},
237 },
238 Expect: "Hello World from hello1",
239 },
240 },
241 },
242 {
David Brownc997a602020-09-09 17:06:21 -0600243 Name: "Wrong ECDSA",
244 ShortName: "wrong-ecdsa",
David Brown5e8dbb92020-09-09 13:17:38 -0600245 Tests: []OneTest{
246 {
David Brownf15a0102020-09-10 08:25:53 -0600247 Build: [][]string{
David Brown5e8dbb92020-09-09 13:17:38 -0600248 {"make", "test-wrong-ecdsa"},
David Brownf15a0102020-09-10 08:25:53 -0600249 },
250 Commands: [][]string{
David Brown5e8dbb92020-09-09 13:17:38 -0600251 {"make", "flash_boot"},
252 },
253 Expect: "Unable to find bootable image",
254 },
255 {
256 Commands: [][]string{
257 {"make", "flash_hello1"},
258 },
259 Expect: "Hello World from hello1",
260 },
261 {
262 Commands: [][]string{
263 {"make", "flash_hello2"},
264 },
265 Expect: "Hello World from hello1",
266 },
267 {
268 Commands: [][]string{
269 {"pyocd", "commander", "-c", "reset"},
270 },
271 Expect: "Hello World from hello1",
272 },
273 },
274 },
275}
276
277type OneTest struct {
David Brownf15a0102020-09-10 08:25:53 -0600278 Build [][]string
David Brown5e8dbb92020-09-09 13:17:38 -0600279 Commands [][]string
280 Expect string
281}