aboutsummaryrefslogtreecommitdiffstats
path: root/test/gtest-port_test.cc
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-07-01 04:58:05 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-07-01 04:58:05 +0000
commitb2db677c9905a34ca6454aa526f7a0cc5cfaeca1 (patch)
tree673f967d6404ea730ccb3d93f30cd3bff5fc8a0e /test/gtest-port_test.cc
parent1b61f16aef4ea5bb2a7b28e759996dab10e0ca72 (diff)
downloadgoogletest-b2db677c9905a34ca6454aa526f7a0cc5cfaeca1.tar.gz
googletest-b2db677c9905a34ca6454aa526f7a0cc5cfaeca1.tar.bz2
googletest-b2db677c9905a34ca6454aa526f7a0cc5cfaeca1.zip
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).
Diffstat (limited to 'test/gtest-port_test.cc')
-rw-r--r--test/gtest-port_test.cc14
1 files changed, 14 insertions, 0 deletions
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 <pthread.h>
+#include <time.h>
#endif // GTEST_OS_MAC
#include <gtest/gtest.h>
@@ -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);
}