Index: sandbox/linux/tests/unit_tests.cc |
diff --git a/sandbox/linux/tests/unit_tests.cc b/sandbox/linux/tests/unit_tests.cc |
index 81079b520f5850c9374de1eebdfc81290e133635..6f9c28a4d819f04696cf1e0b3b6b1b0187bfcedc 100644 |
--- a/sandbox/linux/tests/unit_tests.cc |
+++ b/sandbox/linux/tests/unit_tests.cc |
@@ -42,6 +42,8 @@ int CountThreads() { |
namespace sandbox { |
+extern bool kAllowForkWithThreads; |
+ |
bool IsAndroid() { |
#if defined(OS_ANDROID) |
return true; |
@@ -126,18 +128,25 @@ void UnitTests::RunTestInProcess(UnitTests::Test test, |
// appear as still running in /proc. |
// We poll /proc, with an exponential back-off. At most, we'll sleep around |
// 2^iterations nanoseconds in nanosleep(). |
- for (unsigned int iteration = 0; iteration < 30; iteration++) { |
- struct timespec ts = {0, 1L << iteration /* nanoseconds */}; |
- PCHECK(0 == HANDLE_EINTR(nanosleep(&ts, &ts))); |
- num_threads = CountThreads(); |
- if (kNumExpectedThreads == num_threads) |
- break; |
+ if (!kAllowForkWithThreads) { |
+ for (unsigned int iteration = 0; iteration < 30; iteration++) { |
+ struct timespec ts = {0, 1L << iteration /* nanoseconds */}; |
+ PCHECK(0 == HANDLE_EINTR(nanosleep(&ts, &ts))); |
+ num_threads = CountThreads(); |
+ if (kNumExpectedThreads == num_threads) |
+ break; |
+ } |
+ } |
+ |
+ const std::string multiple_threads_error = |
+ "Running sandbox tests with multiple threads " |
+ "is not supported and will make the tests flaky."; |
+ if (!kAllowForkWithThreads) { |
+ ASSERT_EQ(kNumExpectedThreads, num_threads) << multiple_threads_error; |
+ } else { |
+ LOG(ERROR) << multiple_threads_error; |
} |
- ASSERT_EQ(kNumExpectedThreads, num_threads) |
- << "Running sandbox tests with multiple threads " |
- << "is not supported and will make the tests " |
- << "flaky.\n"; |
int fds[2]; |
ASSERT_EQ(0, pipe(fds)); |
// Check that our pipe is not on one of the standard file descriptor. |