Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2015, Google Inc. |
| 2 | * |
| 3 | * Permission to use, copy, modify, and/or distribute this software for any |
| 4 | * purpose with or without fee is hereby granted, provided that the above |
| 5 | * copyright notice and this permission notice appear in all copies. |
| 6 | * |
| 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 10 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 12 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 13 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ |
| 14 | |
| 15 | package main |
| 16 | |
| 17 | import ( |
| 18 | "bytes" |
| 19 | "encoding/json" |
| 20 | "flag" |
| 21 | "fmt" |
| 22 | "os" |
| 23 | "os/exec" |
| 24 | "path" |
Adam Langley | f4e4272 | 2015-06-04 17:45:09 -0700 | [diff] [blame] | 25 | "strconv" |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 26 | "strings" |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 27 | "sync" |
Adam Langley | f4e4272 | 2015-06-04 17:45:09 -0700 | [diff] [blame] | 28 | "syscall" |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 29 | "time" |
| 30 | ) |
| 31 | |
| 32 | // TODO(davidben): Link tests with the malloc shim and port -malloc-test to this runner. |
| 33 | |
| 34 | var ( |
Adam Langley | f4e4272 | 2015-06-04 17:45:09 -0700 | [diff] [blame] | 35 | useValgrind = flag.Bool("valgrind", false, "If true, run code under valgrind") |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 36 | useCallgrind = flag.Bool("callgrind", false, "If true, run code under valgrind to generate callgrind traces.") |
Adam Langley | f4e4272 | 2015-06-04 17:45:09 -0700 | [diff] [blame] | 37 | useGDB = flag.Bool("gdb", false, "If true, run BoringSSL code under gdb") |
Robert Sloan | 4d1ac50 | 2017-02-06 08:36:14 -0800 | [diff] [blame^] | 38 | useSDE = flag.Bool("sde", false, "If true, run BoringSSL code under Intel's SDE for each supported chip") |
Adam Langley | f4e4272 | 2015-06-04 17:45:09 -0700 | [diff] [blame] | 39 | buildDir = flag.String("build-dir", "build", "The build directory to run the tests from.") |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 40 | numWorkers = flag.Int("num-workers", 1, "Runs the given number of workers when testing.") |
Adam Langley | f4e4272 | 2015-06-04 17:45:09 -0700 | [diff] [blame] | 41 | jsonOutput = flag.String("json-output", "", "The file to output JSON results to.") |
| 42 | mallocTest = flag.Int64("malloc-test", -1, "If non-negative, run each test with each malloc in turn failing from the given number onwards.") |
| 43 | mallocTestDebug = flag.Bool("malloc-test-debug", false, "If true, ask each test to abort rather than fail a malloc. This can be used with a specific value for --malloc-test to identity the malloc failing that is causing problems.") |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 44 | ) |
| 45 | |
Robert Sloan | 4d1ac50 | 2017-02-06 08:36:14 -0800 | [diff] [blame^] | 46 | type test struct { |
| 47 | args []string |
| 48 | // cpu, if not empty, contains an Intel CPU code to simulate. Run |
| 49 | // `sde64 -help` to get a list of these codes. |
| 50 | cpu string |
| 51 | } |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 52 | |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 53 | type result struct { |
| 54 | Test test |
| 55 | Passed bool |
| 56 | Error error |
| 57 | } |
| 58 | |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 59 | // testOutput is a representation of Chromium's JSON test result format. See |
| 60 | // https://www.chromium.org/developers/the-json-test-results-format |
| 61 | type testOutput struct { |
| 62 | Version int `json:"version"` |
| 63 | Interrupted bool `json:"interrupted"` |
| 64 | PathDelimiter string `json:"path_delimiter"` |
| 65 | SecondsSinceEpoch float64 `json:"seconds_since_epoch"` |
| 66 | NumFailuresByType map[string]int `json:"num_failures_by_type"` |
| 67 | Tests map[string]testResult `json:"tests"` |
| 68 | } |
| 69 | |
| 70 | type testResult struct { |
| 71 | Actual string `json:"actual"` |
| 72 | Expected string `json:"expected"` |
| 73 | IsUnexpected bool `json:"is_unexpected"` |
| 74 | } |
| 75 | |
Robert Sloan | 4d1ac50 | 2017-02-06 08:36:14 -0800 | [diff] [blame^] | 76 | // sdeCPUs contains a list of CPU code that we run all tests under when *useSDE |
| 77 | // is true. |
| 78 | var sdeCPUs = []string{ |
| 79 | "p4p", // Pentium4 Prescott |
| 80 | "mrm", // Merom |
| 81 | "pnr", // Penryn |
| 82 | "nhm", // Nehalem |
| 83 | "wsm", // Westmere |
| 84 | "snb", // Sandy Bridge |
| 85 | "ivb", // Ivy Bridge |
| 86 | "hsw", // Haswell |
| 87 | "bdw", // Broadwell |
| 88 | "skx", // Skylake Server |
| 89 | "skl", // Skylake Client |
| 90 | "cnl", // Cannonlake |
| 91 | "knl", // Knights Landing |
| 92 | "slt", // Saltwell |
| 93 | "slm", // Silvermont |
| 94 | "glm", // Goldmont |
| 95 | } |
| 96 | |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 97 | func newTestOutput() *testOutput { |
| 98 | return &testOutput{ |
| 99 | Version: 3, |
| 100 | PathDelimiter: ".", |
| 101 | SecondsSinceEpoch: float64(time.Now().UnixNano()) / float64(time.Second/time.Nanosecond), |
| 102 | NumFailuresByType: make(map[string]int), |
| 103 | Tests: make(map[string]testResult), |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | func (t *testOutput) addResult(name, result string) { |
| 108 | if _, found := t.Tests[name]; found { |
| 109 | panic(name) |
| 110 | } |
| 111 | t.Tests[name] = testResult{ |
| 112 | Actual: result, |
| 113 | Expected: "PASS", |
| 114 | IsUnexpected: result != "PASS", |
| 115 | } |
| 116 | t.NumFailuresByType[result]++ |
| 117 | } |
| 118 | |
| 119 | func (t *testOutput) writeTo(name string) error { |
| 120 | file, err := os.Create(name) |
| 121 | if err != nil { |
| 122 | return err |
| 123 | } |
| 124 | defer file.Close() |
| 125 | out, err := json.MarshalIndent(t, "", " ") |
| 126 | if err != nil { |
| 127 | return err |
| 128 | } |
| 129 | _, err = file.Write(out) |
| 130 | return err |
| 131 | } |
| 132 | |
| 133 | func valgrindOf(dbAttach bool, path string, args ...string) *exec.Cmd { |
David Benjamin | 7c0d06c | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 134 | valgrindArgs := []string{"--error-exitcode=99", "--track-origins=yes", "--leak-check=full", "--quiet"} |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 135 | if dbAttach { |
| 136 | valgrindArgs = append(valgrindArgs, "--db-attach=yes", "--db-command=xterm -e gdb -nw %f %p") |
| 137 | } |
| 138 | valgrindArgs = append(valgrindArgs, path) |
| 139 | valgrindArgs = append(valgrindArgs, args...) |
| 140 | |
| 141 | return exec.Command("valgrind", valgrindArgs...) |
| 142 | } |
| 143 | |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 144 | func callgrindOf(path string, args ...string) *exec.Cmd { |
| 145 | valgrindArgs := []string{"-q", "--tool=callgrind", "--dump-instr=yes", "--collect-jumps=yes", "--callgrind-out-file=" + *buildDir + "/callgrind/callgrind.out.%p"} |
| 146 | valgrindArgs = append(valgrindArgs, path) |
| 147 | valgrindArgs = append(valgrindArgs, args...) |
| 148 | |
| 149 | return exec.Command("valgrind", valgrindArgs...) |
| 150 | } |
| 151 | |
Adam Langley | f4e4272 | 2015-06-04 17:45:09 -0700 | [diff] [blame] | 152 | func gdbOf(path string, args ...string) *exec.Cmd { |
| 153 | xtermArgs := []string{"-e", "gdb", "--args"} |
| 154 | xtermArgs = append(xtermArgs, path) |
| 155 | xtermArgs = append(xtermArgs, args...) |
| 156 | |
| 157 | return exec.Command("xterm", xtermArgs...) |
| 158 | } |
| 159 | |
Robert Sloan | 4d1ac50 | 2017-02-06 08:36:14 -0800 | [diff] [blame^] | 160 | func sdeOf(cpu, path string, args ...string) *exec.Cmd { |
| 161 | sdeArgs := []string{"-" + cpu, "--", path} |
| 162 | sdeArgs = append(sdeArgs, args...) |
| 163 | return exec.Command("sde", sdeArgs...) |
| 164 | } |
| 165 | |
Adam Langley | f4e4272 | 2015-06-04 17:45:09 -0700 | [diff] [blame] | 166 | type moreMallocsError struct{} |
| 167 | |
| 168 | func (moreMallocsError) Error() string { |
| 169 | return "child process did not exhaust all allocation calls" |
| 170 | } |
| 171 | |
| 172 | var errMoreMallocs = moreMallocsError{} |
| 173 | |
| 174 | func runTestOnce(test test, mallocNumToFail int64) (passed bool, err error) { |
Robert Sloan | 4d1ac50 | 2017-02-06 08:36:14 -0800 | [diff] [blame^] | 175 | prog := path.Join(*buildDir, test.args[0]) |
| 176 | args := test.args[1:] |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 177 | var cmd *exec.Cmd |
| 178 | if *useValgrind { |
| 179 | cmd = valgrindOf(false, prog, args...) |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 180 | } else if *useCallgrind { |
| 181 | cmd = callgrindOf(prog, args...) |
Adam Langley | f4e4272 | 2015-06-04 17:45:09 -0700 | [diff] [blame] | 182 | } else if *useGDB { |
| 183 | cmd = gdbOf(prog, args...) |
Robert Sloan | 4d1ac50 | 2017-02-06 08:36:14 -0800 | [diff] [blame^] | 184 | } else if *useSDE { |
| 185 | cmd = sdeOf(test.cpu, prog, args...) |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 186 | } else { |
| 187 | cmd = exec.Command(prog, args...) |
| 188 | } |
| 189 | var stdoutBuf bytes.Buffer |
Adam Langley | f4e4272 | 2015-06-04 17:45:09 -0700 | [diff] [blame] | 190 | var stderrBuf bytes.Buffer |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 191 | cmd.Stdout = &stdoutBuf |
Adam Langley | f4e4272 | 2015-06-04 17:45:09 -0700 | [diff] [blame] | 192 | cmd.Stderr = &stderrBuf |
| 193 | if mallocNumToFail >= 0 { |
| 194 | cmd.Env = os.Environ() |
| 195 | cmd.Env = append(cmd.Env, "MALLOC_NUMBER_TO_FAIL="+strconv.FormatInt(mallocNumToFail, 10)) |
| 196 | if *mallocTestDebug { |
| 197 | cmd.Env = append(cmd.Env, "MALLOC_ABORT_ON_FAIL=1") |
| 198 | } |
| 199 | cmd.Env = append(cmd.Env, "_MALLOC_CHECK=1") |
| 200 | } |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 201 | |
| 202 | if err := cmd.Start(); err != nil { |
| 203 | return false, err |
| 204 | } |
| 205 | if err := cmd.Wait(); err != nil { |
Adam Langley | f4e4272 | 2015-06-04 17:45:09 -0700 | [diff] [blame] | 206 | if exitError, ok := err.(*exec.ExitError); ok { |
| 207 | if exitError.Sys().(syscall.WaitStatus).ExitStatus() == 88 { |
| 208 | return false, errMoreMallocs |
| 209 | } |
| 210 | } |
| 211 | fmt.Print(string(stderrBuf.Bytes())) |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 212 | return false, err |
| 213 | } |
Adam Langley | f4e4272 | 2015-06-04 17:45:09 -0700 | [diff] [blame] | 214 | fmt.Print(string(stderrBuf.Bytes())) |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 215 | |
| 216 | // Account for Windows line-endings. |
| 217 | stdout := bytes.Replace(stdoutBuf.Bytes(), []byte("\r\n"), []byte("\n"), -1) |
| 218 | |
| 219 | if bytes.HasSuffix(stdout, []byte("PASS\n")) && |
| 220 | (len(stdout) == 5 || stdout[len(stdout)-6] == '\n') { |
| 221 | return true, nil |
| 222 | } |
David Benjamin | f31229b | 2017-01-25 14:08:15 -0500 | [diff] [blame] | 223 | |
| 224 | // Also accept a googletest-style pass line. This is left here in |
| 225 | // transition until the tests are all converted and this script made |
| 226 | // unnecessary. |
| 227 | if bytes.Contains(stdout, []byte("\n[ PASSED ]")) { |
| 228 | return true, nil |
| 229 | } |
| 230 | |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 231 | return false, nil |
| 232 | } |
| 233 | |
Adam Langley | f4e4272 | 2015-06-04 17:45:09 -0700 | [diff] [blame] | 234 | func runTest(test test) (bool, error) { |
| 235 | if *mallocTest < 0 { |
| 236 | return runTestOnce(test, -1) |
| 237 | } |
| 238 | |
| 239 | for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { |
| 240 | if passed, err := runTestOnce(test, mallocNumToFail); err != errMoreMallocs { |
| 241 | if err != nil { |
| 242 | err = fmt.Errorf("at malloc %d: %s", mallocNumToFail, err) |
| 243 | } |
| 244 | return passed, err |
| 245 | } |
| 246 | } |
| 247 | } |
| 248 | |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 249 | // shortTestName returns the short name of a test. Except for evp_test, it |
| 250 | // assumes that any argument which ends in .txt is a path to a data file and not |
| 251 | // relevant to the test's uniqueness. |
| 252 | func shortTestName(test test) string { |
| 253 | var args []string |
Robert Sloan | 4d1ac50 | 2017-02-06 08:36:14 -0800 | [diff] [blame^] | 254 | for _, arg := range test.args { |
| 255 | if test.args[0] == "crypto/evp/evp_test" || !strings.HasSuffix(arg, ".txt") { |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 256 | args = append(args, arg) |
| 257 | } |
| 258 | } |
Robert Sloan | 4d1ac50 | 2017-02-06 08:36:14 -0800 | [diff] [blame^] | 259 | return strings.Join(args, " ") + test.cpuMsg() |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 260 | } |
| 261 | |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 262 | // setWorkingDirectory walks up directories as needed until the current working |
| 263 | // directory is the top of a BoringSSL checkout. |
| 264 | func setWorkingDirectory() { |
| 265 | for i := 0; i < 64; i++ { |
| 266 | if _, err := os.Stat("BUILDING.md"); err == nil { |
| 267 | return |
| 268 | } |
| 269 | os.Chdir("..") |
| 270 | } |
| 271 | |
| 272 | panic("Couldn't find BUILDING.md in a parent directory!") |
| 273 | } |
| 274 | |
| 275 | func parseTestConfig(filename string) ([]test, error) { |
| 276 | in, err := os.Open(filename) |
| 277 | if err != nil { |
| 278 | return nil, err |
| 279 | } |
| 280 | defer in.Close() |
| 281 | |
| 282 | decoder := json.NewDecoder(in) |
Robert Sloan | 4d1ac50 | 2017-02-06 08:36:14 -0800 | [diff] [blame^] | 283 | var testArgs [][]string |
| 284 | if err := decoder.Decode(&testArgs); err != nil { |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 285 | return nil, err |
| 286 | } |
Robert Sloan | 4d1ac50 | 2017-02-06 08:36:14 -0800 | [diff] [blame^] | 287 | |
| 288 | var result []test |
| 289 | for _, args := range testArgs { |
| 290 | result = append(result, test{args: args}) |
| 291 | } |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 292 | return result, nil |
| 293 | } |
| 294 | |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 295 | func worker(tests <-chan test, results chan<- result, done *sync.WaitGroup) { |
| 296 | defer done.Done() |
| 297 | for test := range tests { |
| 298 | passed, err := runTest(test) |
| 299 | results <- result{test, passed, err} |
| 300 | } |
| 301 | } |
| 302 | |
Robert Sloan | 4d1ac50 | 2017-02-06 08:36:14 -0800 | [diff] [blame^] | 303 | func (t test) cpuMsg() string { |
| 304 | if len(t.cpu) == 0 { |
| 305 | return "" |
| 306 | } |
| 307 | |
| 308 | return fmt.Sprintf(" (for CPU %q)", t.cpu) |
| 309 | } |
| 310 | |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 311 | func main() { |
| 312 | flag.Parse() |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 313 | setWorkingDirectory() |
| 314 | |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 315 | testCases, err := parseTestConfig("util/all_tests.json") |
Kenny Root | b849459 | 2015-09-25 02:29:14 +0000 | [diff] [blame] | 316 | if err != nil { |
| 317 | fmt.Printf("Failed to parse input: %s\n", err) |
| 318 | os.Exit(1) |
| 319 | } |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 320 | |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 321 | var wg sync.WaitGroup |
| 322 | tests := make(chan test, *numWorkers) |
| 323 | results := make(chan result, *numWorkers) |
| 324 | |
| 325 | for i := 0; i < *numWorkers; i++ { |
| 326 | wg.Add(1) |
| 327 | go worker(tests, results, &wg) |
| 328 | } |
| 329 | |
| 330 | go func() { |
| 331 | for _, test := range testCases { |
Robert Sloan | 4d1ac50 | 2017-02-06 08:36:14 -0800 | [diff] [blame^] | 332 | if *useSDE { |
| 333 | for _, cpu := range sdeCPUs { |
| 334 | testForCPU := test |
| 335 | testForCPU.cpu = cpu |
| 336 | tests <- testForCPU |
| 337 | } |
| 338 | } else { |
| 339 | tests <- test |
| 340 | } |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 341 | } |
| 342 | close(tests) |
| 343 | |
| 344 | wg.Wait() |
| 345 | close(results) |
| 346 | }() |
| 347 | |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 348 | testOutput := newTestOutput() |
| 349 | var failed []test |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 350 | for testResult := range results { |
| 351 | test := testResult.Test |
Robert Sloan | 4d1ac50 | 2017-02-06 08:36:14 -0800 | [diff] [blame^] | 352 | args := test.args |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 353 | |
Robert Sloan | 4d1ac50 | 2017-02-06 08:36:14 -0800 | [diff] [blame^] | 354 | fmt.Printf("%s%s\n", strings.Join(args, " "), test.cpuMsg()) |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 355 | name := shortTestName(test) |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 356 | if testResult.Error != nil { |
Robert Sloan | 4d1ac50 | 2017-02-06 08:36:14 -0800 | [diff] [blame^] | 357 | fmt.Printf("%s failed to complete: %s\n", args[0], testResult.Error) |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 358 | failed = append(failed, test) |
| 359 | testOutput.addResult(name, "CRASHED") |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 360 | } else if !testResult.Passed { |
Robert Sloan | 4d1ac50 | 2017-02-06 08:36:14 -0800 | [diff] [blame^] | 361 | fmt.Printf("%s failed to print PASS on the last line.\n", args[0]) |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 362 | failed = append(failed, test) |
| 363 | testOutput.addResult(name, "FAIL") |
| 364 | } else { |
| 365 | testOutput.addResult(name, "PASS") |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | if *jsonOutput != "" { |
| 370 | if err := testOutput.writeTo(*jsonOutput); err != nil { |
| 371 | fmt.Fprintf(os.Stderr, "Error: %s\n", err) |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | if len(failed) > 0 { |
David Benjamin | 4969cc9 | 2016-04-22 15:02:23 -0400 | [diff] [blame] | 376 | fmt.Printf("\n%d of %d tests failed:\n", len(failed), len(testCases)) |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 377 | for _, test := range failed { |
Robert Sloan | 4d1ac50 | 2017-02-06 08:36:14 -0800 | [diff] [blame^] | 378 | fmt.Printf("\t%s%s\n", strings.Join(test.args, ""), test.cpuMsg()) |
Adam Langley | e9ada86 | 2015-05-11 17:20:37 -0700 | [diff] [blame] | 379 | } |
| 380 | os.Exit(1) |
| 381 | } |
| 382 | |
| 383 | fmt.Printf("\nAll tests passed!\n") |
| 384 | } |