summaryrefslogtreecommitdiff
path: root/src/base/gtest
AgeCommit message (Collapse)Author
2020-01-09tests: Updated gtest/logging.cc to print log rather than fail.Bobby R. Bruce
Previously the `GTestExitLogger.log` function utilized GTest's `ADD_FAILURE_AT` macro. This meant, whenever `GTestExitLogger.log` were called, the calling test would be fail. This is problematic when trying to test code we expect to fail (i.e., when testing the error handling code is working correctly). Therefore, the `log` function now writes to stderr. The `GTestExitLogger` class is used by the `panic` and `fatal` loggers when running GTests. Instead of callnig `exit(1)` they throw a GTest exception, which can be captured in a test using `EXPECT_ANY_THROW(expection_thrower())`. Catching and verifying error logs can be done via: ``` testing::internal::CaptureStderr(); /* * "exception_thrower()" is a method we'd expect to call `fatal` or * `panic`, and therefore exit the simulation with a non-zero exit * code. When running via GTest, an exception is thrown instead. */ EXPECT_ANY_THROW(exception_thrower()); EXPECT_EQ("<error message>", testing::internal::GetCapturedStderr())); ``` Change-Id: I84a5f86bc573668d3dd5b40f626b43108dddb8e9 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23983 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Jason Lowe-Power <jason@lowepower.com> Tested-by: kokoro <noreply+kokoro@google.com>
2017-12-12tests: Add an implementation of the Logger interface for use gtests.Gabe Black
On exiting log types (panic and fatal), the message is set to an ADD_FAILURE_AT macro, and the test is exited by throwing an otherwise unexpected exception. On non-exiting log types, the message is sent to the SUCCEEDED macro which currently doesn't output anything. Change-Id: I1bb569e6cb8308dbc4c3e04eea7a962bd2b1ddd8 Reviewed-on: https://gem5-review.googlesource.com/6264 Maintainer: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>