From 53e0dc4041f660b6517b15b08b496e164be614f1 Mon Sep 17 00:00:00 2001 From: shiqian Date: Thu, 8 Jan 2009 01:10:31 +0000 Subject: Implements the --gtest_death_test_use_fork flag and StaticAssertTypeEq. --- test/gtest-death-test_test.cc | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'test/gtest-death-test_test.cc') diff --git a/test/gtest-death-test_test.cc b/test/gtest-death-test_test.cc index 07268d00..204ec413 100644 --- a/test/gtest-death-test_test.cc +++ b/test/gtest-death-test_test.cc @@ -347,11 +347,13 @@ void SetPthreadFlag() { } // namespace TEST_F(TestForDeathTest, DoesNotExecuteAtforkHooks) { - testing::GTEST_FLAG(death_test_style) = "threadsafe"; - pthread_flag = false; - ASSERT_EQ(0, pthread_atfork(&SetPthreadFlag, NULL, NULL)); - ASSERT_DEATH(_exit(1), ""); - ASSERT_FALSE(pthread_flag); + if (!testing::GTEST_FLAG(death_test_use_fork)) { + testing::GTEST_FLAG(death_test_style) = "threadsafe"; + pthread_flag = false; + ASSERT_EQ(0, pthread_atfork(&SetPthreadFlag, NULL, NULL)); + ASSERT_DEATH(_exit(1), ""); + ASSERT_FALSE(pthread_flag); + } } // Tests that a method of another class can be used in a death test. @@ -561,7 +563,7 @@ TEST_F(TestForDeathTest, AssertDebugDeathAborts) { #endif // _NDEBUG // Tests the *_EXIT family of macros, using a variety of predicates. -TEST_F(TestForDeathTest, ExitMacros) { +static void TestExitMacros() { EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1), ""); ASSERT_EXIT(_exit(42), testing::ExitedWithCode(42), ""); EXPECT_EXIT(raise(SIGKILL), testing::KilledBySignal(SIGKILL), "") << "foo"; @@ -578,6 +580,15 @@ TEST_F(TestForDeathTest, ExitMacros) { }, "This failure is expected, too."); } +TEST_F(TestForDeathTest, ExitMacros) { + TestExitMacros(); +} + +TEST_F(TestForDeathTest, ExitMacrosUsingFork) { + testing::GTEST_FLAG(death_test_use_fork) = true; + TestExitMacros(); +} + TEST_F(TestForDeathTest, InvalidStyle) { testing::GTEST_FLAG(death_test_style) = "rococo"; EXPECT_NONFATAL_FAILURE({ // NOLINT -- cgit v1.2.3