diff --git a/ssl/test/bssl_shim.cc b/ssl/test/bssl_shim.cc index dde25b44..4f27c171 100644 --- a/ssl/test/bssl_shim.cc +++ b/ssl/test/bssl_shim.cc @@ -1485,7 +1485,16 @@ static bool DoExchange(ScopedSSL_SESSION *out_session, SSL_CTX *ssl_ctx, return true; } +class StderrDelimiter { + public: + ~StderrDelimiter() { fprintf(stderr, "--- DONE ---\n"); } +}; + int main(int argc, char **argv) { + // To distinguish ASan's output from ours, add a trailing message to stderr. + // Anything following this line will be considered an error. + StderrDelimiter delimiter; + #if defined(OPENSSL_WINDOWS) /* Initialize Winsock. */ WORD wsa_version = MAKEWORD(2, 2); diff --git a/ssl/test/runner/runner.go b/ssl/test/runner/runner.go index b74f66bb..57f10891 100644 --- a/ssl/test/runner/runner.go +++ b/ssl/test/runner/runner.go @@ -738,6 +738,15 @@ func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { stdout := string(stdoutBuf.Bytes()) stderr := string(stderrBuf.Bytes()) + + // Separate the errors from the shim and those from tools like + // AddressSanitizer. + var extraStderr string + if stderrParts := strings.SplitN(stderr, "--- DONE ---\n", 2); len(stderrParts) == 2 { + stderr = stderrParts[0] + extraStderr = stderrParts[1] + } + failed := err != nil || childErr != nil correctFailure := len(test.expectedError) == 0 || strings.Contains(stderr, test.expectedError) localError := "none" @@ -769,8 +778,8 @@ func runTest(test *testCase, shimPath string, mallocNumToFail int64) error { return fmt.Errorf("%s: local error '%s', child error '%s', stdout:\n%s\nstderr:\n%s", msg, localError, childError, stdout, stderr) } - if !*useValgrind && !failed && len(stderr) > 0 { - println(stderr) + if !*useValgrind && (len(extraStderr) > 0 || (!failed && len(stderr) > 0)) { + return fmt.Errorf("unexpected error output:\n%s\n%s", stderr, extraStderr) } return nil