blob: b2f0b17be5dcdf4f5a622bfd605d75ed91399477 [file] [log] [blame]
David Benjamin54b04fd2023-01-29 11:56:25 -05001// 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
David Benjaminece1f862023-04-24 16:14:08 -040015//go:build ignore
16
David Benjamin491b9212015-02-11 14:18:45 -050017package main
18
19import (
20 "bytes"
David Benjamin6ce93cc2018-10-31 14:48:23 -050021 "errors"
David Benjamin491b9212015-02-11 14:18:45 -050022 "flag"
23 "fmt"
24 "os"
25 "os/exec"
26 "path"
Adam Langley31fa5a42017-04-11 17:07:27 -070027 "runtime"
David Benjamin0b635c52015-05-15 19:08:49 -040028 "strconv"
David Benjamin491b9212015-02-11 14:18:45 -050029 "strings"
Steven Valdez32223942016-03-02 11:53:07 -050030 "sync"
David Benjamin0b635c52015-05-15 19:08:49 -040031 "syscall"
David Benjamince617102018-11-14 17:31:02 -060032
David Benjaminaadb4632020-01-16 18:25:37 -050033 "boringssl.googlesource.com/boringssl/util/testconfig"
David Benjamince617102018-11-14 17:31:02 -060034 "boringssl.googlesource.com/boringssl/util/testresult"
David Benjamin491b9212015-02-11 14:18:45 -050035)
36
37// TODO(davidben): Link tests with the malloc shim and port -malloc-test to this runner.
38
39var (
David Benjamin0b635c52015-05-15 19:08:49 -040040 useValgrind = flag.Bool("valgrind", false, "If true, run code under valgrind")
Steven Valdezab14a4a2016-02-29 16:58:26 -050041 useCallgrind = flag.Bool("callgrind", false, "If true, run code under valgrind to generate callgrind traces.")
David Benjamin0b635c52015-05-15 19:08:49 -040042 useGDB = flag.Bool("gdb", false, "If true, run BoringSSL code under gdb")
Adam Langleye212f272017-02-03 08:52:21 -080043 useSDE = flag.Bool("sde", false, "If true, run BoringSSL code under Intel's SDE for each supported chip")
David Benjamin799676c2017-05-10 16:56:02 -040044 sdePath = flag.String("sde-path", "sde", "The path to find the sde binary.")
David Benjamin0b635c52015-05-15 19:08:49 -040045 buildDir = flag.String("build-dir", "build", "The build directory to run the tests from.")
Adam Langley31fa5a42017-04-11 17:07:27 -070046 numWorkers = flag.Int("num-workers", runtime.NumCPU(), "Runs the given number of workers when testing.")
David Benjamin0b635c52015-05-15 19:08:49 -040047 jsonOutput = flag.String("json-output", "", "The file to output JSON results to.")
48 mallocTest = flag.Int64("malloc-test", -1, "If non-negative, run each test with each malloc in turn failing from the given number onwards.")
49 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.")
David Benjamin6ce93cc2018-10-31 14:48:23 -050050 simulateARMCPUs = flag.Bool("simulate-arm-cpus", simulateARMCPUsDefault(), "If true, runs tests simulating different ARM CPUs.")
David Benjamin491b9212015-02-11 14:18:45 -050051)
52
David Benjamin6ce93cc2018-10-31 14:48:23 -050053func simulateARMCPUsDefault() bool {
David Benjamine1148bd2020-01-16 18:58:14 -050054 return (runtime.GOOS == "linux" || runtime.GOOS == "android") && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64")
David Benjamin6ce93cc2018-10-31 14:48:23 -050055}
56
Adam Langleye212f272017-02-03 08:52:21 -080057type test struct {
David Benjaminaadb4632020-01-16 18:25:37 -050058 testconfig.Test
59
David Benjaminced6e762017-09-28 15:17:05 -040060 shard, numShards int
David Benjamin6ce93cc2018-10-31 14:48:23 -050061 // cpu, if not empty, contains a code to simulate. For SDE, run `sde64
62 // -help` to get a list of these codes. For ARM, see gtest_main.cc for
63 // the supported values.
Adam Langleye212f272017-02-03 08:52:21 -080064 cpu string
65}
David Benjamin491b9212015-02-11 14:18:45 -050066
Steven Valdez32223942016-03-02 11:53:07 -050067type result struct {
68 Test test
69 Passed bool
70 Error error
71}
72
Adam Langleye212f272017-02-03 08:52:21 -080073// sdeCPUs contains a list of CPU code that we run all tests under when *useSDE
74// is true.
75var sdeCPUs = []string{
76 "p4p", // Pentium4 Prescott
77 "mrm", // Merom
78 "pnr", // Penryn
79 "nhm", // Nehalem
80 "wsm", // Westmere
81 "snb", // Sandy Bridge
82 "ivb", // Ivy Bridge
83 "hsw", // Haswell
84 "bdw", // Broadwell
Adam Langleye212f272017-02-03 08:52:21 -080085 "slt", // Saltwell
86 "slm", // Silvermont
87 "glm", // Goldmont
Adam Langley41439432020-04-08 09:16:07 -070088 "glp", // Goldmont Plus
89 "tnt", // Tremont
90 "skl", // Skylake
91 "cnl", // Cannon Lake
92 "icl", // Ice Lake
93 "skx", // Skylake server
94 "clx", // Cascade Lake
95 "cpx", // Cooper Lake
96 "icx", // Ice Lake server
97 "knl", // Knights landing
98 "knm", // Knights mill
99 "tgl", // Tiger Lake
Adam Langleye212f272017-02-03 08:52:21 -0800100}
101
David Benjamin6ce93cc2018-10-31 14:48:23 -0500102var armCPUs = []string{
103 "none", // No support for any ARM extensions.
104 "neon", // Support for NEON.
105 "crypto", // Support for NEON and crypto extensions.
106}
107
David Benjamin491b9212015-02-11 14:18:45 -0500108func valgrindOf(dbAttach bool, path string, args ...string) *exec.Cmd {
David Benjamind2ba8892016-09-20 19:41:04 -0400109 valgrindArgs := []string{"--error-exitcode=99", "--track-origins=yes", "--leak-check=full", "--quiet"}
David Benjamin491b9212015-02-11 14:18:45 -0500110 if dbAttach {
111 valgrindArgs = append(valgrindArgs, "--db-attach=yes", "--db-command=xterm -e gdb -nw %f %p")
112 }
113 valgrindArgs = append(valgrindArgs, path)
114 valgrindArgs = append(valgrindArgs, args...)
115
116 return exec.Command("valgrind", valgrindArgs...)
117}
118
Steven Valdezab14a4a2016-02-29 16:58:26 -0500119func callgrindOf(path string, args ...string) *exec.Cmd {
120 valgrindArgs := []string{"-q", "--tool=callgrind", "--dump-instr=yes", "--collect-jumps=yes", "--callgrind-out-file=" + *buildDir + "/callgrind/callgrind.out.%p"}
121 valgrindArgs = append(valgrindArgs, path)
122 valgrindArgs = append(valgrindArgs, args...)
123
124 return exec.Command("valgrind", valgrindArgs...)
125}
126
David Benjamin0b635c52015-05-15 19:08:49 -0400127func gdbOf(path string, args ...string) *exec.Cmd {
128 xtermArgs := []string{"-e", "gdb", "--args"}
129 xtermArgs = append(xtermArgs, path)
130 xtermArgs = append(xtermArgs, args...)
131
132 return exec.Command("xterm", xtermArgs...)
133}
134
Adam Langleye212f272017-02-03 08:52:21 -0800135func sdeOf(cpu, path string, args ...string) *exec.Cmd {
David Benjaminc5304e42017-07-17 16:15:16 -0400136 sdeArgs := []string{"-" + cpu}
137 // The kernel's vdso code for gettimeofday sometimes uses the RDTSCP
138 // instruction. Although SDE has a -chip_check_vsyscall flag that
139 // excludes such code by default, it does not seem to work. Instead,
140 // pass the -chip_check_exe_only flag which retains test coverage when
141 // statically linked and excludes the vdso.
142 if cpu == "p4p" || cpu == "pnr" || cpu == "mrm" || cpu == "slt" {
143 sdeArgs = append(sdeArgs, "-chip_check_exe_only")
144 }
145 sdeArgs = append(sdeArgs, "--", path)
Adam Langleye212f272017-02-03 08:52:21 -0800146 sdeArgs = append(sdeArgs, args...)
David Benjamin799676c2017-05-10 16:56:02 -0400147 return exec.Command(*sdePath, sdeArgs...)
Adam Langleye212f272017-02-03 08:52:21 -0800148}
149
David Benjamin6ce93cc2018-10-31 14:48:23 -0500150var (
151 errMoreMallocs = errors.New("child process did not exhaust all allocation calls")
152 errTestSkipped = errors.New("test was skipped")
153)
David Benjamin0b635c52015-05-15 19:08:49 -0400154
155func runTestOnce(test test, mallocNumToFail int64) (passed bool, err error) {
David Benjaminaadb4632020-01-16 18:25:37 -0500156 prog := path.Join(*buildDir, test.Cmd[0])
157 args := append([]string{}, test.Cmd[1:]...)
David Benjamin6ce93cc2018-10-31 14:48:23 -0500158 if *simulateARMCPUs && test.cpu != "" {
Adam Langley7de94982019-10-17 09:15:37 -0700159 args = append(args, "--cpu="+test.cpu)
David Benjamin17d553d2018-12-21 17:58:36 -0600160 }
161 if *useSDE {
162 // SDE is neither compatible with the unwind tester nor automatically
163 // detected.
164 args = append(args, "--no_unwind_tests")
David Benjamin6ce93cc2018-10-31 14:48:23 -0500165 }
David Benjamin491b9212015-02-11 14:18:45 -0500166 var cmd *exec.Cmd
167 if *useValgrind {
168 cmd = valgrindOf(false, prog, args...)
Steven Valdezab14a4a2016-02-29 16:58:26 -0500169 } else if *useCallgrind {
170 cmd = callgrindOf(prog, args...)
David Benjamin0b635c52015-05-15 19:08:49 -0400171 } else if *useGDB {
172 cmd = gdbOf(prog, args...)
Adam Langleye212f272017-02-03 08:52:21 -0800173 } else if *useSDE {
174 cmd = sdeOf(test.cpu, prog, args...)
David Benjamin491b9212015-02-11 14:18:45 -0500175 } else {
176 cmd = exec.Command(prog, args...)
177 }
David Benjamin5c1d5d82022-01-31 18:43:13 -0500178 if test.Env != nil || test.numShards != 0 {
Adam Langley7de94982019-10-17 09:15:37 -0700179 cmd.Env = make([]string, len(os.Environ()))
180 copy(cmd.Env, os.Environ())
David Benjamin5c1d5d82022-01-31 18:43:13 -0500181 }
182 if test.Env != nil {
David Benjaminaadb4632020-01-16 18:25:37 -0500183 cmd.Env = append(cmd.Env, test.Env...)
Adam Langley7de94982019-10-17 09:15:37 -0700184 }
David Benjamin5c1d5d82022-01-31 18:43:13 -0500185 if test.numShards != 0 {
186 cmd.Env = append(cmd.Env, fmt.Sprintf("GTEST_SHARD_INDEX=%d", test.shard))
187 cmd.Env = append(cmd.Env, fmt.Sprintf("GTEST_TOTAL_SHARDS=%d", test.numShards))
188 }
David Benjamin634b0e32017-02-04 11:14:57 -0500189 var outBuf bytes.Buffer
190 cmd.Stdout = &outBuf
191 cmd.Stderr = &outBuf
David Benjamin0b635c52015-05-15 19:08:49 -0400192 if mallocNumToFail >= 0 {
193 cmd.Env = os.Environ()
194 cmd.Env = append(cmd.Env, "MALLOC_NUMBER_TO_FAIL="+strconv.FormatInt(mallocNumToFail, 10))
195 if *mallocTestDebug {
196 cmd.Env = append(cmd.Env, "MALLOC_ABORT_ON_FAIL=1")
197 }
198 cmd.Env = append(cmd.Env, "_MALLOC_CHECK=1")
199 }
David Benjamin491b9212015-02-11 14:18:45 -0500200
201 if err := cmd.Start(); err != nil {
202 return false, err
203 }
204 if err := cmd.Wait(); err != nil {
David Benjamin0b635c52015-05-15 19:08:49 -0400205 if exitError, ok := err.(*exec.ExitError); ok {
David Benjamin6ce93cc2018-10-31 14:48:23 -0500206 switch exitError.Sys().(syscall.WaitStatus).ExitStatus() {
207 case 88:
David Benjamin0b635c52015-05-15 19:08:49 -0400208 return false, errMoreMallocs
David Benjamin6ce93cc2018-10-31 14:48:23 -0500209 case 89:
210 fmt.Print(string(outBuf.Bytes()))
211 return false, errTestSkipped
David Benjamin0b635c52015-05-15 19:08:49 -0400212 }
213 }
David Benjamin634b0e32017-02-04 11:14:57 -0500214 fmt.Print(string(outBuf.Bytes()))
David Benjamin491b9212015-02-11 14:18:45 -0500215 return false, err
216 }
217
218 // Account for Windows line-endings.
David Benjamin634b0e32017-02-04 11:14:57 -0500219 stdout := bytes.Replace(outBuf.Bytes(), []byte("\r\n"), []byte("\n"), -1)
David Benjamin491b9212015-02-11 14:18:45 -0500220
221 if bytes.HasSuffix(stdout, []byte("PASS\n")) &&
222 (len(stdout) == 5 || stdout[len(stdout)-6] == '\n') {
223 return true, nil
224 }
David Benjamin96628432017-01-19 19:05:47 -0500225
226 // Also accept a googletest-style pass line. This is left here in
227 // transition until the tests are all converted and this script made
228 // unnecessary.
229 if bytes.Contains(stdout, []byte("\n[ PASSED ]")) {
230 return true, nil
231 }
232
David Benjamin634b0e32017-02-04 11:14:57 -0500233 fmt.Print(string(outBuf.Bytes()))
David Benjamin491b9212015-02-11 14:18:45 -0500234 return false, nil
235}
236
David Benjamin0b635c52015-05-15 19:08:49 -0400237func runTest(test test) (bool, error) {
238 if *mallocTest < 0 {
239 return runTestOnce(test, -1)
240 }
241
242 for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ {
243 if passed, err := runTestOnce(test, mallocNumToFail); err != errMoreMallocs {
244 if err != nil {
245 err = fmt.Errorf("at malloc %d: %s", mallocNumToFail, err)
246 }
247 return passed, err
248 }
249 }
250}
251
Adam Langley117da412015-06-10 17:32:25 -0700252// setWorkingDirectory walks up directories as needed until the current working
253// directory is the top of a BoringSSL checkout.
254func setWorkingDirectory() {
255 for i := 0; i < 64; i++ {
David Benjamin95aaf4a2015-09-03 12:09:36 -0400256 if _, err := os.Stat("BUILDING.md"); err == nil {
Adam Langley117da412015-06-10 17:32:25 -0700257 return
258 }
259 os.Chdir("..")
260 }
261
David Benjamin95aaf4a2015-09-03 12:09:36 -0400262 panic("Couldn't find BUILDING.md in a parent directory!")
Adam Langley117da412015-06-10 17:32:25 -0700263}
264
Steven Valdez32223942016-03-02 11:53:07 -0500265func worker(tests <-chan test, results chan<- result, done *sync.WaitGroup) {
266 defer done.Done()
267 for test := range tests {
268 passed, err := runTest(test)
269 results <- result{test, passed, err}
270 }
271}
272
David Benjaminced6e762017-09-28 15:17:05 -0400273func (t test) shortName() string {
David Benjamin5c1d5d82022-01-31 18:43:13 -0500274 return strings.Join(t.Cmd, " ") + t.shardMsg() + t.cpuMsg() + t.envMsg()
Adam Langley7de94982019-10-17 09:15:37 -0700275}
276
277func SpaceIf(returnSpace bool) string {
278 if !returnSpace {
279 return ""
280 }
281 return " "
David Benjaminced6e762017-09-28 15:17:05 -0400282}
283
284func (t test) longName() string {
David Benjamin5c1d5d82022-01-31 18:43:13 -0500285 return strings.Join(t.Env, " ") + SpaceIf(len(t.Env) != 0) + strings.Join(t.Cmd, " ") + t.shardMsg() + t.cpuMsg()
David Benjaminced6e762017-09-28 15:17:05 -0400286}
287
288func (t test) shardMsg() string {
289 if t.numShards == 0 {
290 return ""
291 }
292
293 return fmt.Sprintf(" [shard %d/%d]", t.shard+1, t.numShards)
294}
295
Adam Langleye212f272017-02-03 08:52:21 -0800296func (t test) cpuMsg() string {
297 if len(t.cpu) == 0 {
298 return ""
299 }
300
301 return fmt.Sprintf(" (for CPU %q)", t.cpu)
302}
303
Adam Langley7de94982019-10-17 09:15:37 -0700304func (t test) envMsg() string {
David Benjaminaadb4632020-01-16 18:25:37 -0500305 if len(t.Env) == 0 {
Adam Langley7de94982019-10-17 09:15:37 -0700306 return ""
307 }
308
309 return " (custom environment)"
310}
311
David Benjamin3d14a152017-06-07 14:02:03 -0400312func (t test) getGTestShards() ([]test, error) {
David Benjamin63f4b802023-06-30 14:13:18 -0400313 if *numWorkers == 1 || !t.Shard {
David Benjamin3d14a152017-06-07 14:02:03 -0400314 return []test{t}, nil
315 }
316
David Benjamin5c1d5d82022-01-31 18:43:13 -0500317 shards := make([]test, *numWorkers)
David Benjaminced6e762017-09-28 15:17:05 -0400318 for i := range shards {
David Benjamin5c1d5d82022-01-31 18:43:13 -0500319 shards[i] = t
320 shards[i].shard = i
321 shards[i].numShards = *numWorkers
David Benjaminced6e762017-09-28 15:17:05 -0400322 }
323
David Benjamin3d14a152017-06-07 14:02:03 -0400324 return shards, nil
325}
326
David Benjamin491b9212015-02-11 14:18:45 -0500327func main() {
328 flag.Parse()
Adam Langley117da412015-06-10 17:32:25 -0700329 setWorkingDirectory()
330
David Benjaminaadb4632020-01-16 18:25:37 -0500331 testCases, err := testconfig.ParseTestConfig("util/all_tests.json")
Adam Langley117da412015-06-10 17:32:25 -0700332 if err != nil {
333 fmt.Printf("Failed to parse input: %s\n", err)
334 os.Exit(1)
335 }
David Benjamin491b9212015-02-11 14:18:45 -0500336
Steven Valdez32223942016-03-02 11:53:07 -0500337 var wg sync.WaitGroup
338 tests := make(chan test, *numWorkers)
David Benjamin8b9e7802016-03-02 18:23:21 -0500339 results := make(chan result, *numWorkers)
Steven Valdez32223942016-03-02 11:53:07 -0500340
341 for i := 0; i < *numWorkers; i++ {
David Benjamin8b9e7802016-03-02 18:23:21 -0500342 wg.Add(1)
Steven Valdez32223942016-03-02 11:53:07 -0500343 go worker(tests, results, &wg)
344 }
345
Steven Valdez32223942016-03-02 11:53:07 -0500346 go func() {
David Benjaminaadb4632020-01-16 18:25:37 -0500347 for _, baseTest := range testCases {
348 test := test{Test: baseTest}
Adam Langleye212f272017-02-03 08:52:21 -0800349 if *useSDE {
David Benjaminaadb4632020-01-16 18:25:37 -0500350 if test.SkipSDE {
351 continue
352 }
David Benjamin3d14a152017-06-07 14:02:03 -0400353 // SDE generates plenty of tasks and gets slower
354 // with additional sharding.
Adam Langleye212f272017-02-03 08:52:21 -0800355 for _, cpu := range sdeCPUs {
356 testForCPU := test
357 testForCPU.cpu = cpu
358 tests <- testForCPU
359 }
David Benjamin6ce93cc2018-10-31 14:48:23 -0500360 } else if *simulateARMCPUs {
361 // This mode is run instead of the default path,
362 // so also include the native flow.
363 tests <- test
364 for _, cpu := range armCPUs {
365 testForCPU := test
366 testForCPU.cpu = cpu
367 tests <- testForCPU
368 }
Adam Langleye212f272017-02-03 08:52:21 -0800369 } else {
David Benjamin3d14a152017-06-07 14:02:03 -0400370 shards, err := test.getGTestShards()
371 if err != nil {
372 fmt.Printf("Error listing tests: %s\n", err)
373 os.Exit(1)
374 }
375 for _, shard := range shards {
376 tests <- shard
377 }
Adam Langleye212f272017-02-03 08:52:21 -0800378 }
David Benjamin8b9e7802016-03-02 18:23:21 -0500379 }
380 close(tests)
381
Steven Valdez32223942016-03-02 11:53:07 -0500382 wg.Wait()
383 close(results)
384 }()
385
David Benjamince617102018-11-14 17:31:02 -0600386 testOutput := testresult.NewResults()
David Benjamin6ce93cc2018-10-31 14:48:23 -0500387 var failed, skipped []test
Steven Valdez32223942016-03-02 11:53:07 -0500388 for testResult := range results {
389 test := testResult.Test
David Benjaminaadb4632020-01-16 18:25:37 -0500390 args := test.Cmd
David Benjamin5f237bc2015-02-11 17:14:15 -0500391
David Benjamin6ce93cc2018-10-31 14:48:23 -0500392 if testResult.Error == errTestSkipped {
393 fmt.Printf("%s\n", test.longName())
394 fmt.Printf("%s was skipped\n", args[0])
395 skipped = append(skipped, test)
David Benjamince617102018-11-14 17:31:02 -0600396 testOutput.AddSkip(test.longName())
David Benjamin6ce93cc2018-10-31 14:48:23 -0500397 } else if testResult.Error != nil {
David Benjaminced6e762017-09-28 15:17:05 -0400398 fmt.Printf("%s\n", test.longName())
Adam Langleye212f272017-02-03 08:52:21 -0800399 fmt.Printf("%s failed to complete: %s\n", args[0], testResult.Error)
David Benjamin491b9212015-02-11 14:18:45 -0500400 failed = append(failed, test)
David Benjamince617102018-11-14 17:31:02 -0600401 testOutput.AddResult(test.longName(), "CRASH")
Steven Valdez32223942016-03-02 11:53:07 -0500402 } else if !testResult.Passed {
David Benjaminced6e762017-09-28 15:17:05 -0400403 fmt.Printf("%s\n", test.longName())
Adam Langleye212f272017-02-03 08:52:21 -0800404 fmt.Printf("%s failed to print PASS on the last line.\n", args[0])
David Benjamin491b9212015-02-11 14:18:45 -0500405 failed = append(failed, test)
David Benjamince617102018-11-14 17:31:02 -0600406 testOutput.AddResult(test.longName(), "FAIL")
David Benjamin5f237bc2015-02-11 17:14:15 -0500407 } else {
David Benjaminced6e762017-09-28 15:17:05 -0400408 fmt.Printf("%s\n", test.shortName())
David Benjamince617102018-11-14 17:31:02 -0600409 testOutput.AddResult(test.longName(), "PASS")
David Benjamin491b9212015-02-11 14:18:45 -0500410 }
411 }
412
David Benjamin5f237bc2015-02-11 17:14:15 -0500413 if *jsonOutput != "" {
David Benjamince617102018-11-14 17:31:02 -0600414 if err := testOutput.WriteToFile(*jsonOutput); err != nil {
David Benjamin5f237bc2015-02-11 17:14:15 -0500415 fmt.Fprintf(os.Stderr, "Error: %s\n", err)
416 }
417 }
David Benjamin2ab7a862015-04-04 17:02:18 -0400418
David Benjamin6ce93cc2018-10-31 14:48:23 -0500419 if len(skipped) > 0 {
420 fmt.Printf("\n%d of %d tests were skipped:\n", len(skipped), len(testCases))
421 for _, test := range skipped {
David Benjamin5c1d5d82022-01-31 18:43:13 -0500422 fmt.Printf("\t%s\n", test.shortName())
David Benjamin6ce93cc2018-10-31 14:48:23 -0500423 }
424 }
425
David Benjamin2ab7a862015-04-04 17:02:18 -0400426 if len(failed) > 0 {
David Benjamin8b9e7802016-03-02 18:23:21 -0500427 fmt.Printf("\n%d of %d tests failed:\n", len(failed), len(testCases))
David Benjamin2ab7a862015-04-04 17:02:18 -0400428 for _, test := range failed {
David Benjamin5c1d5d82022-01-31 18:43:13 -0500429 fmt.Printf("\t%s\n", test.shortName())
David Benjamin2ab7a862015-04-04 17:02:18 -0400430 }
431 os.Exit(1)
432 }
433
434 fmt.Printf("\nAll tests passed!\n")
David Benjamin491b9212015-02-11 14:18:45 -0500435}