From ba28dfc381ff87257ffe075f48fd27d60ab2e27e Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Tue, 15 Nov 2016 17:47:21 +0900 Subject: [PATCH] Add a -repeat-until-failure flag to runner. When debugging a flaky test, it's useful to be able to run a given test over and over. Change-Id: I1a7b38792215550b242eb8238214d873d41becb6 Reviewed-on: https://boringssl-review.googlesource.com/12301 Reviewed-by: David Benjamin --- ssl/test/runner/runner.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ssl/test/runner/runner.go b/ssl/test/runner/runner.go index 918618df..8a18e8f0 100644 --- a/ssl/test/runner/runner.go +++ b/ssl/test/runner/runner.go @@ -62,6 +62,7 @@ var ( looseErrors = flag.Bool("loose-errors", false, "If true, allow shims to report an untranslated error code.") shimConfigFile = flag.String("shim-config", "", "A config file to use to configure the tests for this shim.") includeDisabled = flag.Bool("include-disabled", false, "If true, also runs disabled tests.") + repeatUntilFailure = flag.Bool("repeat-until-failure", false, "If true, the first selected test will be run repeatedly until failure.") ) // ShimConfigurations is used with the “json” package and represents a shim @@ -9468,10 +9469,7 @@ func worker(statusChan chan statusMsg, c chan *testCase, shimPath string, wg *sy for test := range c { var err error - if *mallocTest < 0 { - statusChan <- statusMsg{test: test, started: true} - err = runTest(test, shimPath, -1) - } else { + if *mallocTest >= 0 { for mallocNumToFail := int64(*mallocTest); ; mallocNumToFail++ { statusChan <- statusMsg{test: test, started: true} if err = runTest(test, shimPath, mallocNumToFail); err != errMoreMallocs { @@ -9481,6 +9479,14 @@ func worker(statusChan chan statusMsg, c chan *testCase, shimPath string, wg *sy break } } + } else if *repeatUntilFailure { + for err == nil { + statusChan <- statusMsg{test: test, started: true} + err = runTest(test, shimPath, -1) + } + } else { + statusChan <- statusMsg{test: test, started: true} + err = runTest(test, shimPath, -1) } statusChan <- statusMsg{test: test, err: err} } @@ -9640,6 +9646,11 @@ func main() { if matched { foundTest = true testChan <- &testCases[i] + + // Only run one test if repeating until failure. + if *repeatUntilFailure { + break + } } }