Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Unified Diff: sandbox/linux/tests/unit_tests.cc

Issue 242383003: Linux sandbox test: temporarily allow fork() with threads (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sandbox/linux/tests/main.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « sandbox/linux/tests/main.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698