aboutsummaryrefslogtreecommitdiffstats
path: root/test/gtest-death-test_test.cc
diff options
context:
space:
mode:
authorshiqian <shiqian@861a406c-534a-0410-8894-cb66d6ee9925>2009-01-08 01:10:31 +0000
committershiqian <shiqian@861a406c-534a-0410-8894-cb66d6ee9925>2009-01-08 01:10:31 +0000
commit53e0dc4041f660b6517b15b08b496e164be614f1 (patch)
treefc8832cf39d3e67358299901d7474fb9a7b2dfe4 /test/gtest-death-test_test.cc
parent0efb17dc540ff5fbc9bf2ca370e42347d4d3a6d9 (diff)
downloadgoogletest-53e0dc4041f660b6517b15b08b496e164be614f1.tar.gz
googletest-53e0dc4041f660b6517b15b08b496e164be614f1.tar.bz2
googletest-53e0dc4041f660b6517b15b08b496e164be614f1.zip
Implements the --gtest_death_test_use_fork flag and StaticAssertTypeEq.
Diffstat (limited to 'test/gtest-death-test_test.cc')
-rw-r--r--test/gtest-death-test_test.cc23
1 files changed, 17 insertions, 6 deletions
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