diff options
author | jln@chromium.org <jln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-18 05:34:14 +0000 |
---|---|---|
committer | jln@chromium.org <jln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-18 05:34:14 +0000 |
commit | ec24d9ecbebdc4512ce6ad197dcf0b6613f0f8cc (patch) | |
tree | 85c37cc99c9c70e44ed3dc180852f1454fad04e0 /sandbox | |
parent | 85ecf33e5bd8dc4ba14f7739ab7cf89309bd3140 (diff) | |
download | chromium_src-ec24d9ecbebdc4512ce6ad197dcf0b6613f0f8cc.zip chromium_src-ec24d9ecbebdc4512ce6ad197dcf0b6613f0f8cc.tar.gz chromium_src-ec24d9ecbebdc4512ce6ad197dcf0b6613f0f8cc.tar.bz2 |
Linux sandbox test: temporarily allow fork() with threads
In sandbox tests, we temporarily allow fork() with threads.
BUG=364751
R=hamaji@chromium.org
TBR=mseaborn
NOTRY=true
Review URL: https://codereview.chromium.org/242383003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@264747 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox')
-rw-r--r-- | sandbox/linux/tests/main.cc | 3 | ||||
-rw-r--r-- | sandbox/linux/tests/unit_tests.cc | 29 |
2 files changed, 22 insertions, 10 deletions
diff --git a/sandbox/linux/tests/main.cc b/sandbox/linux/tests/main.cc index 9ee384d..a736ea2 100644 --- a/sandbox/linux/tests/main.cc +++ b/sandbox/linux/tests/main.cc @@ -10,6 +10,9 @@ #include "testing/gtest/include/gtest/gtest.h" namespace sandbox { + +extern const bool kAllowForkWithThreads = false; + namespace { // Check for leaks in our tests. diff --git a/sandbox/linux/tests/unit_tests.cc b/sandbox/linux/tests/unit_tests.cc index 81079b5..6f9c28a 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. |