23 #include <gtest/gtest.h> 27 struct TestingMacrosFixture :
public ::testing::Test
29 TestingMacrosFixture() =
default;
36 ::testing::AssertionFailure() :
37 ::testing::AssertionSuccess();
44 ::testing::AssertionFailure() :
45 ::testing::AssertionSuccess();
49 static void sig_term_handler(
int)
51 std::cout <<
"Received sigterm." << std::endl;
61 TEST(ForkAndRun, succeeding_client_and_service_result_in_correct_return_value)
68 ASSERT_FALSE(ClientFailed(result));
69 ASSERT_FALSE(ServiceFailed(result));
72 TEST(ForkAndRun, succeeding_client_and_failing_service_result_in_correct_return_value)
79 EXPECT_FALSE(ClientFailed(result));
80 EXPECT_TRUE(ServiceFailed(result));
83 TEST(ForkAndRun, failing_client_and_failing_service_result_in_correct_return_value)
90 EXPECT_TRUE(ClientFailed(result));
91 EXPECT_TRUE(ServiceFailed(result));
94 TEST(ForkAndRun, throwing_client_is_reported_as_failing)
101 EXPECT_TRUE(ClientFailed(result));
102 EXPECT_FALSE(ServiceFailed(result));
105 TEST(ForkAndRun, exiting_with_failure_client_is_reported_as_failing)
112 EXPECT_TRUE(ClientFailed(result));
113 EXPECT_FALSE(ServiceFailed(result));
116 TEST(ForkAndRun, aborting_client_is_reported_as_failing)
123 EXPECT_TRUE(ClientFailed(result));
124 EXPECT_FALSE(ServiceFailed(result));
149 #include <core/posix/backtrace.h>
151 TEST(BacktraceSymbolDemangling, demangling_a_cpp_symbol_works)
153 const char* ref =
"tests/fork_and_run_test(_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS0_12UnitTestImplEbEET0_PT_MS4_FS3_vEPKc+0x4b) [0x4591f8]";
154 const char* ref_demangled =
"bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*)";
157 EXPECT_TRUE(symbol->is_cxx());
158 EXPECT_EQ(ref, symbol->raw());
159 EXPECT_EQ(ref_demangled, symbol->demangled());
ForkAndRunResult
The ForkAndRunResult enum models the different failure modes of fork_and_run.
TESTP(TestingMacros, test_fp_macro_reports_success_for_passing_test,{return core::posix::exit::Status::success;}) TESTP_F(TestingMacrosFixture
CORE_POSIX_DLL_PUBLIC ForkAndRunResult fork_and_run(const std::function< core::posix::exit::Status()> &service, const std::function< core::posix::exit::Status()> &client)
Forks two processes for both the service and the client.
static std::shared_ptr< Symbol > for_testing_from_raw_symbol(const char *symbol)
test_fp_macro_reports_success_for_passing_test
Special value indicating no bit being set.
#define TESTP_F(test_fixture, test_name, CODE)
TEST(ForkAndRun, succeeding_client_and_service_result_in_correct_return_value)
CORE_POSIX_DLL_PUBLIC std::ostream & cout() noexcept(true)
Access this process's stdout.
DISABLED_test_fp_macro_reports_success_for_failing_test