Print errors better in FileTestGTest.

Rather than clear them, even on failure, detect if an individual test
failed and dump the error queue there. We already do this at the GTest
level in ErrorTestEventListener, but that is too coarse-grained for the
file tests.

Change-Id: I3437626dcf3ec43f6fddd98153b0af73dbdcce84
Reviewed-on: https://boringssl-review.googlesource.com/19966
Reviewed-by: Steven Valdez <svaldez@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
This commit is contained in:
David Benjamin 2017-09-03 13:18:48 -04:00 committed by CQ bot account: commit-bot@chromium.org
parent 24e36099ce
commit 28d6979b7e
2 changed files with 19 additions and 3 deletions

View File

@ -410,7 +410,6 @@ TEST(EVPTest, TestVectors) {
EXPECT_EQ(t->GetAttributeOrDie("Error"), ERR_reason_error_string(err)); EXPECT_EQ(t->GetAttributeOrDie("Error"), ERR_reason_error_string(err));
} else if (!result) { } else if (!result) {
ADD_FAILURE() << "Operation unexpectedly failed."; ADD_FAILURE() << "Operation unexpectedly failed.";
ERR_print_errors_fp(stdout);
} }
}); });
} }

View File

@ -81,10 +81,27 @@ void FileTestGTest(const char *path, std::function<void(FileTest *)> run_test) {
break; break;
} }
const testing::TestResult *test_result =
testing::UnitTest::GetInstance()->current_test_info()->result();
int before_part_count = test_result->total_part_count();
SCOPED_TRACE(testing::Message() << path << ", line " << t.start_line()); SCOPED_TRACE(testing::Message() << path << ", line " << t.start_line());
run_test(&t); run_test(&t);
// Clean up the error queue for the next test. // Check for failures from the most recent test.
bool failed = false;
for (int i = before_part_count; i < test_result->total_part_count(); i++) {
if (test_result->GetTestPartResult(i).failed()) {
failed = true;
break;
}
}
// Clean up the error queue for the next test, reporting it on failure.
if (failed) {
ERR_print_errors_fp(stdout);
} else {
ERR_clear_error(); ERR_clear_error();
} }
} }
}