Ensure runner notices post-main stderr output.

If LeakSanitizer fires something on a test that's expected to fail, runner will
swallow it. Have stderr output always end in a "--- DONE ---" marker and treat
all output following that as a test failure.

Change-Id: Ia8fd9dfcaf48dd23972ab8f906d240bcb6badfe2
Reviewed-on: https://boringssl-review.googlesource.com/7281
Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
David Benjamin 2016-03-02 10:12:06 -05:00 committed by Adam Langley
parent 3cd8196f14
commit ff3a1498da
2 changed files with 20 additions and 2 deletions

View File

@ -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);

View File

@ -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