From b2db677c9905a34ca6454aa526f7a0cc5cfaeca1 Mon Sep 17 00:00:00 2001 From: "zhanyong.wan" Date: Wed, 1 Jul 2009 04:58:05 +0000 Subject: Reduces the flakiness of gtest-port_test on Mac; improves the Python tests; hides methods that we don't want to publish; makes win-dbg8 the default scons configuration (all by Vlad Losev). --- test/gtest-port_test.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/gtest-port_test.cc') diff --git a/test/gtest-port_test.cc b/test/gtest-port_test.cc index f4560f19..37880a7f 100644 --- a/test/gtest-port_test.cc +++ b/test/gtest-port_test.cc @@ -35,6 +35,7 @@ #if GTEST_OS_MAC #include +#include #endif // GTEST_OS_MAC #include @@ -110,6 +111,19 @@ TEST(GetThreadCountTest, ReturnsCorrectValue) { void* dummy; ASSERT_EQ(0, pthread_join(thread_id, &dummy)); + + // MacOS X may not immediately report the updated thread count after + // joining a thread, causing flakiness in this test. To counter that, we + // wait for up to .5 seconds for the OS to report the correct value. + for (int i = 0; i < 5; ++i) { + if (GetThreadCount() == 1) + break; + + timespec time; + time.tv_sec = 0; + time.tv_nsec = 100L * 1000 * 1000; // .1 seconds. + nanosleep(&time, NULL); + } EXPECT_EQ(1, GetThreadCount()); pthread_mutex_destroy(&mutex); } -- cgit v1.2.3