You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by id...@apache.org on 2014/05/09 21:13:17 UTC

git commit: ProcTest.MultipleThreads waits for /proc to update.

Repository: mesos
Updated Branches:
  refs/heads/master ad4f129cd -> 56eac2371


ProcTest.MultipleThreads waits for /proc to update.

Review: https://reviews.apache.org/r/21122


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/56eac237
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/56eac237
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/56eac237

Branch: refs/heads/master
Commit: 56eac23716ef718fd888033a2074ff7319d6e676
Parents: ad4f129
Author: Ian Downes <id...@twitter.com>
Authored: Tue May 6 10:54:03 2014 -0700
Committer: Ian Downes <id...@twitter.com>
Committed: Fri May 9 12:12:22 2014 -0700

----------------------------------------------------------------------
 .../3rdparty/stout/tests/proc_tests.cpp         | 22 ++++++++++++++++++++
 1 file changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/56eac237/3rdparty/libprocess/3rdparty/stout/tests/proc_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/proc_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/proc_tests.cpp
index abd109b..c723bd7 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/proc_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/proc_tests.cpp
@@ -107,4 +107,26 @@ TEST(ProcTest, MultipleThreads)
     EXPECT_EQ(0, pthread_cancel(pthreads[i]));
     EXPECT_EQ(0, pthread_join(pthreads[i], NULL));
   }
+
+  // There is some delay before /proc updates after the threads have
+  // terminated. We wait until this occurs before completing the test to ensure
+  // a call to proc::threads in a subsequent test will not return these
+  // threads, e.g., if tests are shuffled and ProcTest.SingleThread occurs
+  // after this test.
+  Duration elapsed = Duration::zero();
+  while (true) {
+    threads = proc::threads(::getpid());
+    ASSERT_SOME(threads);
+
+    if (threads.get().size() == 1) {
+      break;
+    }
+
+    if (elapsed > Seconds(1)) {
+      FAIL() << "Failed to wait for /proc to update for terminated threads";
+    }
+
+    os::sleep(Milliseconds(5));
+    elapsed += Milliseconds(5);
+  }
 }