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 | { |
| 16 | Commands: [][]string{ |
| 17 | {"make", "test-good-rsa"}, |
| 18 | {"make", "flash_boot"}, |
| 19 | }, |
| 20 | Expect: "Unable to find bootable image", |
| 21 | }, |
| 22 | { |
| 23 | Commands: [][]string{ |
| 24 | {"make", "flash_hello1"}, |
| 25 | }, |
| 26 | Expect: "Hello World from hello1", |
| 27 | }, |
| 28 | { |
| 29 | Commands: [][]string{ |
| 30 | {"make", "flash_hello2"}, |
| 31 | }, |
| 32 | Expect: "Hello World from hello2", |
| 33 | }, |
| 34 | { |
| 35 | Commands: [][]string{ |
| 36 | {"pyocd", "commander", "-c", "reset"}, |
| 37 | }, |
| 38 | Expect: "Hello World from hello1", |
| 39 | }, |
| 40 | }, |
| 41 | }, |
| 42 | { |
David Brown | c997a60 | 2020-09-09 17:06:21 -0600 | [diff] [blame^] | 43 | Name: "Good ECDSA", |
| 44 | ShortName: "good-ecdsa", |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 45 | Tests: []OneTest{ |
| 46 | { |
| 47 | Commands: [][]string{ |
| 48 | {"make", "test-good-ecdsa"}, |
| 49 | {"make", "flash_boot"}, |
| 50 | }, |
| 51 | Expect: "Unable to find bootable image", |
| 52 | }, |
| 53 | { |
| 54 | Commands: [][]string{ |
| 55 | {"make", "flash_hello1"}, |
| 56 | }, |
| 57 | Expect: "Hello World from hello1", |
| 58 | }, |
| 59 | { |
| 60 | Commands: [][]string{ |
| 61 | {"make", "flash_hello2"}, |
| 62 | }, |
| 63 | Expect: "Hello World from hello2", |
| 64 | }, |
| 65 | { |
| 66 | Commands: [][]string{ |
| 67 | {"pyocd", "commander", "-c", "reset"}, |
| 68 | }, |
| 69 | Expect: "Hello World from hello1", |
| 70 | }, |
| 71 | }, |
| 72 | }, |
| 73 | { |
David Brown | c997a60 | 2020-09-09 17:06:21 -0600 | [diff] [blame^] | 74 | Name: "Overwrite", |
| 75 | ShortName: "overwrite", |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 76 | Tests: []OneTest{ |
| 77 | { |
| 78 | Commands: [][]string{ |
| 79 | {"make", "test-overwrite"}, |
| 80 | {"make", "flash_boot"}, |
| 81 | }, |
| 82 | Expect: "Unable to find bootable image", |
| 83 | }, |
| 84 | { |
| 85 | Commands: [][]string{ |
| 86 | {"make", "flash_hello1"}, |
| 87 | }, |
| 88 | Expect: "Hello World from hello1", |
| 89 | }, |
| 90 | { |
| 91 | Commands: [][]string{ |
| 92 | {"make", "flash_hello2"}, |
| 93 | }, |
| 94 | Expect: "Hello World from hello2", |
| 95 | }, |
| 96 | { |
| 97 | Commands: [][]string{ |
| 98 | {"pyocd", "commander", "-c", "reset"}, |
| 99 | }, |
| 100 | Expect: "Hello World from hello2", |
| 101 | }, |
| 102 | }, |
| 103 | }, |
| 104 | { |
David Brown | c997a60 | 2020-09-09 17:06:21 -0600 | [diff] [blame^] | 105 | Name: "Bad RSA", |
| 106 | ShortName: "bad-rsa-upgrade", |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 107 | Tests: []OneTest{ |
| 108 | { |
| 109 | Commands: [][]string{ |
| 110 | {"make", "test-bad-rsa-upgrade"}, |
| 111 | {"make", "flash_boot"}, |
| 112 | }, |
| 113 | Expect: "Unable to find bootable image", |
| 114 | }, |
| 115 | { |
| 116 | Commands: [][]string{ |
| 117 | {"make", "flash_hello1"}, |
| 118 | }, |
| 119 | Expect: "Hello World from hello1", |
| 120 | }, |
| 121 | { |
| 122 | Commands: [][]string{ |
| 123 | {"make", "flash_hello2"}, |
| 124 | }, |
| 125 | Expect: "Hello World from hello1", |
| 126 | }, |
| 127 | { |
| 128 | Commands: [][]string{ |
| 129 | {"pyocd", "commander", "-c", "reset"}, |
| 130 | }, |
| 131 | Expect: "Hello World from hello1", |
| 132 | }, |
| 133 | }, |
| 134 | }, |
| 135 | { |
David Brown | c997a60 | 2020-09-09 17:06:21 -0600 | [diff] [blame^] | 136 | Name: "Bad RSA", |
| 137 | ShortName: "bad-ecdsa-upgrade", |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 138 | Tests: []OneTest{ |
| 139 | { |
| 140 | Commands: [][]string{ |
| 141 | {"make", "test-bad-ecdsa-upgrade"}, |
| 142 | {"make", "flash_boot"}, |
| 143 | }, |
| 144 | Expect: "Unable to find bootable image", |
| 145 | }, |
| 146 | { |
| 147 | Commands: [][]string{ |
| 148 | {"make", "flash_hello1"}, |
| 149 | }, |
| 150 | Expect: "Hello World from hello1", |
| 151 | }, |
| 152 | { |
| 153 | Commands: [][]string{ |
| 154 | {"make", "flash_hello2"}, |
| 155 | }, |
| 156 | Expect: "Hello World from hello1", |
| 157 | }, |
| 158 | { |
| 159 | Commands: [][]string{ |
| 160 | {"pyocd", "commander", "-c", "reset"}, |
| 161 | }, |
| 162 | Expect: "Hello World from hello1", |
| 163 | }, |
| 164 | }, |
| 165 | }, |
| 166 | { |
David Brown | c997a60 | 2020-09-09 17:06:21 -0600 | [diff] [blame^] | 167 | Name: "No bootcheck", |
| 168 | ShortName: "no-bootcheck", |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 169 | Tests: []OneTest{ |
| 170 | { |
| 171 | Commands: [][]string{ |
| 172 | {"make", "test-no-bootcheck"}, |
| 173 | {"make", "flash_boot"}, |
| 174 | }, |
| 175 | Expect: "Unable to find bootable image", |
| 176 | }, |
| 177 | { |
| 178 | Commands: [][]string{ |
| 179 | {"make", "flash_hello1"}, |
| 180 | }, |
| 181 | Expect: "Hello World from hello1", |
| 182 | }, |
| 183 | { |
| 184 | Commands: [][]string{ |
| 185 | {"make", "flash_hello2"}, |
| 186 | }, |
| 187 | Expect: "Hello World from hello1", |
| 188 | }, |
| 189 | { |
| 190 | Commands: [][]string{ |
| 191 | {"pyocd", "commander", "-c", "reset"}, |
| 192 | }, |
| 193 | Expect: "Hello World from hello1", |
| 194 | }, |
| 195 | }, |
| 196 | }, |
| 197 | { |
David Brown | c997a60 | 2020-09-09 17:06:21 -0600 | [diff] [blame^] | 198 | Name: "Wrong RSA", |
| 199 | ShortName: "wrong-rsa", |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 200 | Tests: []OneTest{ |
| 201 | { |
| 202 | Commands: [][]string{ |
| 203 | {"make", "test-wrong-rsa"}, |
| 204 | {"make", "flash_boot"}, |
| 205 | }, |
| 206 | Expect: "Unable to find bootable image", |
| 207 | }, |
| 208 | { |
| 209 | Commands: [][]string{ |
| 210 | {"make", "flash_hello1"}, |
| 211 | }, |
| 212 | Expect: "Hello World from hello1", |
| 213 | }, |
| 214 | { |
| 215 | Commands: [][]string{ |
| 216 | {"make", "flash_hello2"}, |
| 217 | }, |
| 218 | Expect: "Hello World from hello1", |
| 219 | }, |
| 220 | { |
| 221 | Commands: [][]string{ |
| 222 | {"pyocd", "commander", "-c", "reset"}, |
| 223 | }, |
| 224 | Expect: "Hello World from hello1", |
| 225 | }, |
| 226 | }, |
| 227 | }, |
| 228 | { |
David Brown | c997a60 | 2020-09-09 17:06:21 -0600 | [diff] [blame^] | 229 | Name: "Wrong ECDSA", |
| 230 | ShortName: "wrong-ecdsa", |
David Brown | 5e8dbb9 | 2020-09-09 13:17:38 -0600 | [diff] [blame] | 231 | Tests: []OneTest{ |
| 232 | { |
| 233 | Commands: [][]string{ |
| 234 | {"make", "test-wrong-ecdsa"}, |
| 235 | {"make", "flash_boot"}, |
| 236 | }, |
| 237 | Expect: "Unable to find bootable image", |
| 238 | }, |
| 239 | { |
| 240 | Commands: [][]string{ |
| 241 | {"make", "flash_hello1"}, |
| 242 | }, |
| 243 | Expect: "Hello World from hello1", |
| 244 | }, |
| 245 | { |
| 246 | Commands: [][]string{ |
| 247 | {"make", "flash_hello2"}, |
| 248 | }, |
| 249 | Expect: "Hello World from hello1", |
| 250 | }, |
| 251 | { |
| 252 | Commands: [][]string{ |
| 253 | {"pyocd", "commander", "-c", "reset"}, |
| 254 | }, |
| 255 | Expect: "Hello World from hello1", |
| 256 | }, |
| 257 | }, |
| 258 | }, |
| 259 | } |
| 260 | |
| 261 | type OneTest struct { |
| 262 | Commands [][]string |
| 263 | Expect string |
| 264 | } |