Merge pull request #3465 from mbinna:bazel_qnx
PiperOrigin-RevId: 382189077
diff --git a/googletest/include/gtest/internal/gtest-death-test-internal.h b/googletest/include/gtest/internal/gtest-death-test-internal.h
index 490296d..867a840 100644
--- a/googletest/include/gtest/internal/gtest-death-test-internal.h
+++ b/googletest/include/gtest/internal/gtest-death-test-internal.h
@@ -236,8 +236,6 @@
gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \
break; \
} \
- default: \
- break; \
} \
} \
} else \
diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc
index 2697355..16d30c4 100644
--- a/googletest/test/googletest-port-test.cc
+++ b/googletest/test/googletest-port-test.cc
@@ -289,36 +289,61 @@
}
TEST(GetThreadCountTest, ReturnsCorrectValue) {
- const size_t starting_count = GetThreadCount();
- pthread_t thread_id;
+ size_t starting_count;
+ size_t thread_count_after_create;
+ size_t thread_count_after_join;
- internal::Mutex mutex;
- {
- internal::MutexLock lock(&mutex);
- pthread_attr_t attr;
- ASSERT_EQ(0, pthread_attr_init(&attr));
- ASSERT_EQ(0, pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE));
+ // We can't guarantee that no other thread was created or destroyed between
+ // any two calls to GetThreadCount(). We make multiple attempts, hoping that
+ // background noise is not constant and we would see the "right" values at
+ // some point.
+ for (int attempt = 0; attempt < 20; ++attempt) {
+ starting_count = GetThreadCount();
+ pthread_t thread_id;
- const int status = pthread_create(&thread_id, &attr, &ThreadFunc, &mutex);
- ASSERT_EQ(0, pthread_attr_destroy(&attr));
- ASSERT_EQ(0, status);
- EXPECT_EQ(starting_count + 1, GetThreadCount());
+ internal::Mutex mutex;
+ {
+ internal::MutexLock lock(&mutex);
+ pthread_attr_t attr;
+ ASSERT_EQ(0, pthread_attr_init(&attr));
+ ASSERT_EQ(0, pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE));
+
+ const int status = pthread_create(&thread_id, &attr, &ThreadFunc, &mutex);
+ ASSERT_EQ(0, pthread_attr_destroy(&attr));
+ ASSERT_EQ(0, status);
+ }
+
+ thread_count_after_create = GetThreadCount();
+
+ void* dummy;
+ ASSERT_EQ(0, pthread_join(thread_id, &dummy));
+
+ // Join before we decide whether we need to retry the test. Retry if an
+ // arbitrary other thread was created or destroyed in the meantime.
+ if (thread_count_after_create != starting_count + 1) continue;
+
+ // The OS 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.
+ bool thread_count_matches = false;
+ for (int i = 0; i < 5; ++i) {
+ thread_count_after_join = GetThreadCount();
+ if (thread_count_after_join == starting_count) {
+ thread_count_matches = true;
+ break;
+ }
+
+ SleepMilliseconds(100);
+ }
+
+ // Retry if an arbitrary other thread was created or destroyed.
+ if (!thread_count_matches) continue;
+
+ break;
}
- void* dummy;
- ASSERT_EQ(0, pthread_join(thread_id, &dummy));
-
- // The OS 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() == starting_count)
- break;
-
- SleepMilliseconds(100);
- }
-
- EXPECT_EQ(starting_count, GetThreadCount());
+ EXPECT_EQ(thread_count_after_create, starting_count + 1);
+ EXPECT_EQ(thread_count_after_join, starting_count);
}
#else
TEST(GetThreadCountTest, ReturnsZeroWhenUnableToCountThreads) {
diff --git a/library.json b/library.json
deleted file mode 100644
index f61bf00..0000000
--- a/library.json
+++ /dev/null
@@ -1,62 +0,0 @@
-{
- "name": "googletest",
- "keywords": "unittest, unit, test, gtest, gmock",
- "description": "googletest is a testing framework developed by the Testing Technology team with Google's specific requirements and constraints in mind. No matter whether you work on Linux, Windows, or a Mac, if you write C++ code, googletest can help you. And it supports any kind of tests, not just unit tests.",
- "license": "BSD-3-Clause",
- "homepage": "https://github.com/google/googletest/blob/master/README.md",
- "repository": {
- "type": "git",
- "url": "https://github.com/google/googletest.git"
- },
- "version": "1.10.0",
- "frameworks": "arduino",
- "platforms": [
- "espressif32",
- "espressif8266"
- ],
- "export": {
- "include": [
- "googlemock/include/*",
- "googlemock/src/*",
- "googletest/include/*",
- "googletest/src/*"
- ],
- "exclude": [
- "ci",
- "googlemock/cmake",
- "googlemock/scripts",
- "googlemock/test",
- "googlemock/CMakeLists.txt",
- "googletest/cmake",
- "googletest/scripts",
- "googletest/test",
- "googletest/CMakeLists.txt"
- ]
- },
- "build": {
- "flags": [
- "-Igooglemock/include",
- "-Igooglemock",
- "-Igoogletest/include",
- "-Igoogletest"
- ],
- "srcFilter": [
- "+<*>",
- "-<.git/>",
- "-<googlemock>",
- "-<googlemock/test/>",
- "-<googlemock/src>",
- "+<googlemock/src/gmock-all.cc>",
- "+<googletest/src/gtest-all.cc>",
- "+<googlemock/src/gmock_main.cc>",
- "-<googletest>",
- "-<googletest/codegear/>",
- "-<googletest/samples>",
- "-<googletest/test/>",
- "-<googletest/xcode>",
- "-<googletest/src>",
- "+<googletest/src/gtest-all.cc>",
- "+<googletest/src/gtest_main.cc>"
- ]
- }
-}