Initial commit
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
diff --git a/googletest/test/googletest-port-test.cc
|
||||
index 9f05a01..9ee4061 100644
|
||||
--- a/googletest/test/googletest-port-test.cc
|
||||
+++ b/googletest/test/googletest-port-test.cc
|
||||
@@ -304,7 +304,12 @@ TEST(GetThreadCountTest, ReturnsCorrectValue) {
|
||||
// some point.
|
||||
for (int attempt = 0; attempt < 20; ++attempt) {
|
||||
starting_count = GetThreadCount();
|
||||
+ if (starting_count == 0) {
|
||||
+ GTEST_SKIP() << "GetThreadCount() is unavailable on this system.";
|
||||
+ }
|
||||
+
|
||||
pthread_t thread_id;
|
||||
+ bool thread_count_matches = false;
|
||||
|
||||
internal::Mutex mutex;
|
||||
{
|
||||
@@ -317,7 +322,22 @@ TEST(GetThreadCountTest, ReturnsCorrectValue) {
|
||||
ASSERT_EQ(0, pthread_attr_destroy(&attr));
|
||||
ASSERT_EQ(0, status);
|
||||
|
||||
- thread_count_after_create = GetThreadCount();
|
||||
+ // The OS may not immediately report the updated thread count after
|
||||
+ // creating a thread, causing flakiness in this test. To counter that,
|
||||
+ // wait for up to .5 seconds for the OS to report the correct value
|
||||
+ // while keeping the worker thread blocked on the mutex.
|
||||
+ for (int i = 0; i < 5; ++i) {
|
||||
+ thread_count_after_create = GetThreadCount();
|
||||
+ if (thread_count_after_create == 0) {
|
||||
+ GTEST_SKIP() << "GetThreadCount() is unavailable on this system.";
|
||||
+ }
|
||||
+ if (thread_count_after_create == starting_count + 1) {
|
||||
+ thread_count_matches = true;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
+ }
|
||||
}
|
||||
|
||||
void* dummy;
|
||||
@@ -325,14 +345,17 @@ TEST(GetThreadCountTest, ReturnsCorrectValue) {
|
||||
|
||||
// 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;
|
||||
+ if (!thread_count_matches) 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;
|
||||
+ thread_count_matches = false;
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
thread_count_after_join = GetThreadCount();
|
||||
+ if (thread_count_after_join == 0) {
|
||||
+ GTEST_SKIP() << "GetThreadCount() is unavailable on this system.";
|
||||
+ }
|
||||
if (thread_count_after_join == starting_count) {
|
||||
thread_count_matches = true;
|
||||
break;
|
||||
@@ -0,0 +1,42 @@
|
||||
[build]
|
||||
type = "cmake"
|
||||
|
||||
[build.flags]
|
||||
build_dir = "build"
|
||||
configure = [
|
||||
"-Wno-dev",
|
||||
"-DBUILD_SHARED_LIBS=ON",
|
||||
"-Dgtest_build_tests=ON",
|
||||
"-DGOOGLETEST_VERSION=$version",
|
||||
"-G Ninja"
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
build = [
|
||||
"cmake",
|
||||
"python",
|
||||
"ninja"
|
||||
]
|
||||
runtime = [
|
||||
"glibc",
|
||||
"libunwind",
|
||||
"libcxx",
|
||||
]
|
||||
optional = [ "python" ]
|
||||
|
||||
[package]
|
||||
description = "Google Test - C++ testing utility"
|
||||
homepage = "https://github.com/google/googletest"
|
||||
license = "BSD-3-Clause"
|
||||
name = "gtest"
|
||||
version = "1.17.0"
|
||||
|
||||
[[source]]
|
||||
extract_dir = "$name-$version"
|
||||
sha256 = "65fab701d9829d38cb77c14acdc431d2108bfdbf8979e40eb8ae567edf10b27c"
|
||||
url = "https://github.com/google/googletest/releases/download/v$version/googletest-$version.tar.gz"
|
||||
patches = [ "googletest-1.17.0-fix-flaky-getthreadcount-test.patch" ]
|
||||
|
||||
[[manual_sources]]
|
||||
file = "googletest-1.17.0-fix-flaky-getthreadcount-test.patch"
|
||||
sha256 = "b2:9f05b125c2deaf16e04b48de1bbdcf954cf44c745c16b7ee3c0492e2e36e43a50f10ef73f7f17e52ac8e4ce861b4b57546a5eb4d09c164c6d7b4a68cf857045b"
|
||||
Reference in New Issue
Block a user