David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 1 | // Package mcutests |
| 2 | package mcutests // github.com/JuulLabs-OSS/mcuboot/samples/zephyr/mcutests |
| 3 | |
| 4 | // The main driver of this consists of a series of tests. Each test |
| 5 | // then contains a series of commands and expect results. |
| 6 | var Tests = []struct { |
David Brown | c997a60 | 2020-09-09 17:06:21 -0600 | [diff] [blame] | 7 | Name string |
| 8 | ShortName string |
| 9 | Tests []OneTest |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 10 | }{ |
| 11 | { |
David Brown | c997a60 | 2020-09-09 17:06:21 -0600 | [diff] [blame] | 12 | Name: "Good RSA", |
| 13 | ShortName: "good-rsa", |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 14 | Tests: []OneTest{ |
| 15 | { |
David Brown | f15a010 | 2020-09-10 08:25:53 -0600 | [diff] [blame^] | 16 | Build: [][]string{ |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 17 | {"make", "test-good-rsa"}, |
David Brown | f15a010 | 2020-09-10 08:25:53 -0600 | [diff] [blame^] | 18 | }, |
| 19 | Commands: [][]string{ |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 20 | {"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 Brown | c997a60 | 2020-09-09 17:06:21 -0600 | [diff] [blame] | 45 | Name: "Good ECDSA", |
| 46 | ShortName: "good-ecdsa", |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 47 | Tests: []OneTest{ |
| 48 | { |
David Brown | f15a010 | 2020-09-10 08:25:53 -0600 | [diff] [blame^] | 49 | Build: [][]string{ |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 50 | {"make", "test-good-ecdsa"}, |
David Brown | f15a010 | 2020-09-10 08:25:53 -0600 | [diff] [blame^] | 51 | }, |
| 52 | Commands: [][]string{ |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 53 | {"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 Brown | c997a60 | 2020-09-09 17:06:21 -0600 | [diff] [blame] | 78 | Name: "Overwrite", |
| 79 | ShortName: "overwrite", |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 80 | Tests: []OneTest{ |
| 81 | { |
David Brown | f15a010 | 2020-09-10 08:25:53 -0600 | [diff] [blame^] | 82 | Build: [][]string{ |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 83 | {"make", "test-overwrite"}, |
David Brown | f15a010 | 2020-09-10 08:25:53 -0600 | [diff] [blame^] | 84 | }, |
| 85 | Commands: [][]string{ |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 86 | {"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 Brown | c997a60 | 2020-09-09 17:06:21 -0600 | [diff] [blame] | 111 | Name: "Bad RSA", |
| 112 | ShortName: "bad-rsa-upgrade", |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 113 | Tests: []OneTest{ |
| 114 | { |
David Brown | f15a010 | 2020-09-10 08:25:53 -0600 | [diff] [blame^] | 115 | Build: [][]string{ |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 116 | {"make", "test-bad-rsa-upgrade"}, |
David Brown | f15a010 | 2020-09-10 08:25:53 -0600 | [diff] [blame^] | 117 | }, |
| 118 | Commands: [][]string{ |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 119 | {"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 Brown | c997a60 | 2020-09-09 17:06:21 -0600 | [diff] [blame] | 144 | Name: "Bad RSA", |
| 145 | ShortName: "bad-ecdsa-upgrade", |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 146 | Tests: []OneTest{ |
| 147 | { |
David Brown | f15a010 | 2020-09-10 08:25:53 -0600 | [diff] [blame^] | 148 | Build: [][]string{ |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 149 | {"make", "test-bad-ecdsa-upgrade"}, |
David Brown | f15a010 | 2020-09-10 08:25:53 -0600 | [diff] [blame^] | 150 | }, |
| 151 | Commands: [][]string{ |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 152 | {"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 Brown | c997a60 | 2020-09-09 17:06:21 -0600 | [diff] [blame] | 177 | Name: "No bootcheck", |
| 178 | ShortName: "no-bootcheck", |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 179 | Tests: []OneTest{ |
| 180 | { |
David Brown | f15a010 | 2020-09-10 08:25:53 -0600 | [diff] [blame^] | 181 | Build: [][]string{ |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 182 | {"make", "test-no-bootcheck"}, |
David Brown | f15a010 | 2020-09-10 08:25:53 -0600 | [diff] [blame^] | 183 | }, |
| 184 | Commands: [][]string{ |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 185 | {"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 Brown | c997a60 | 2020-09-09 17:06:21 -0600 | [diff] [blame] | 210 | Name: "Wrong RSA", |
| 211 | ShortName: "wrong-rsa", |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 212 | Tests: []OneTest{ |
| 213 | { |
David Brown | f15a010 | 2020-09-10 08:25:53 -0600 | [diff] [blame^] | 214 | Build: [][]string{ |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 215 | {"make", "test-wrong-rsa"}, |
David Brown | f15a010 | 2020-09-10 08:25:53 -0600 | [diff] [blame^] | 216 | }, |
| 217 | Commands: [][]string{ |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 218 | {"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 Brown | c997a60 | 2020-09-09 17:06:21 -0600 | [diff] [blame] | 243 | Name: "Wrong ECDSA", |
| 244 | ShortName: "wrong-ecdsa", |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 245 | Tests: []OneTest{ |
| 246 | { |
David Brown | f15a010 | 2020-09-10 08:25:53 -0600 | [diff] [blame^] | 247 | Build: [][]string{ |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 248 | {"make", "test-wrong-ecdsa"}, |
David Brown | f15a010 | 2020-09-10 08:25:53 -0600 | [diff] [blame^] | 249 | }, |
| 250 | Commands: [][]string{ |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 251 | {"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 | |
| 277 | type OneTest struct { |
David Brown | f15a010 | 2020-09-10 08:25:53 -0600 | [diff] [blame^] | 278 | Build [][]string |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 279 | Commands [][]string |
| 280 | Expect string |
| 281 | } |