diff --git a/e2e_tests/functional_test.cc b/e2e_tests/functional_test.cc index 42e2f57a..49eec378 100644 --- a/e2e_tests/functional_test.cc +++ b/e2e_tests/functional_test.cc @@ -217,6 +217,18 @@ void GoogleTestExpectationsDontAbortInUnitTestModeImpl( EXPECT_THAT_LOG(std_out, HasSubstr("[ FAILED ] MySuite.GoogleTestAssert")); EXPECT_THAT(status, Ne(ExitCode(0))); +#ifndef FUZZTEST_USE_CENTIPEDE + // There is the gtest stack on stdout, and no stack on stderr. + EXPECT_THAT_LOG(std_out, AllOf(HasSubstr("GoogleTestExpect("), + HasSubstr("GoogleTestAssert("))); + // We remove the reproducer first because it also contains the function name. + EXPECT_THAT(RemoveReproducer(RemoveReproducer(std_err, "MySuite", + "GoogleTestExpect", ".*"), + "MySuite", "GoogleTestAssert", ".*"), + AllOf(Not(HasSubstr("GoogleTestExpect(")), + Not(HasSubstr("GoogleTestAssert(")))); +#endif + // There is no repro example on stdout, and there is one on stderr. EXPECT_THAT_LOG( std_out, @@ -1668,6 +1680,9 @@ TEST_P(FuzzingModeCrashFindingTest, GoogleTestExpectationsStopTheFuzzer) { ExpectTargetAbort(status, std_err); #ifndef FUZZTEST_USE_CENTIPEDE + // There is a stack both on stdout and stderr. + EXPECT_THAT_LOG(std_out, HasSubstr("GoogleTestExpect(")); + EXPECT_THAT_LOG(std_err, HasSubstr("GoogleTestExpect(")); // There is the repro example only on stderr. EXPECT_THAT_LOG(std_out, @@ -1683,6 +1698,9 @@ TEST_P(FuzzingModeCrashFindingTest, GoogleTestAssertionsStopTheFuzzer) { ExpectTargetAbort(status, std_err); #ifndef FUZZTEST_USE_CENTIPEDE + // There is a stack both on stdout and stderr. + EXPECT_THAT_LOG(std_out, HasSubstr("GoogleTestAssert(")); + EXPECT_THAT_LOG(std_err, HasSubstr("GoogleTestAssert(")); // There is the repro example only on stderr. EXPECT_THAT_LOG(std_out, diff --git a/fuzztest/BUILD b/fuzztest/BUILD index 1bbd23ca..ad8e66de 100644 --- a/fuzztest/BUILD +++ b/fuzztest/BUILD @@ -106,6 +106,8 @@ cc_library( testonly = 1, srcs = ["fuzztest_gtest_main.cc"], deps = [ + "@abseil-cpp//absl/debugging:failure_signal_handler", + "@abseil-cpp//absl/debugging:symbolize", "@com_google_fuzztest//fuzztest:init_fuzztest", "@googletest//:gtest", ], diff --git a/fuzztest/CMakeLists.txt b/fuzztest/CMakeLists.txt index d5aaedb4..e42edc2f 100644 --- a/fuzztest/CMakeLists.txt +++ b/fuzztest/CMakeLists.txt @@ -130,6 +130,9 @@ fuzztest_cc_library( SRCS "fuzztest_gtest_main.cc" DEPS + absl::debugging + absl::failure_signal_handler + absl::symbolize fuzztest::init_fuzztest GTest::gtest ) diff --git a/fuzztest/fuzztest_gtest_main.cc b/fuzztest/fuzztest_gtest_main.cc index 709d0364..69026589 100644 --- a/fuzztest/fuzztest_gtest_main.cc +++ b/fuzztest/fuzztest_gtest_main.cc @@ -14,8 +14,14 @@ #include "gtest/gtest.h" #include "./fuzztest/init_fuzztest.h" +#include "absl/debugging/failure_signal_handler.h" +#include "absl/debugging/symbolize.h" int main(int argc, char** argv) { + absl::InitializeSymbolizer(argv[0]); + absl::FailureSignalHandlerOptions options; + options.call_previous_handler = true; + absl::InstallFailureSignalHandler(options); testing::InitGoogleTest(&argc, argv); // We call fuzztest::ParseAbslFlags rather than absl::ParseCommandLine // since the latter would complain about any unknown flags that need