diff options
Diffstat (limited to 'test/syscalls/linux')
-rw-r--r-- | test/syscalls/linux/proc.cc | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/test/syscalls/linux/proc.cc b/test/syscalls/linux/proc.cc index e508ce27f..61a421788 100644 --- a/test/syscalls/linux/proc.cc +++ b/test/syscalls/linux/proc.cc @@ -2162,7 +2162,13 @@ class BlockingChild { return tid_; } - void Join() { Stop(); } + void Join() { + { + absl::MutexLock ml(&mu_); + stop_ = true; + } + thread_.Join(); + } private: void Start() { @@ -2172,11 +2178,6 @@ class BlockingChild { mu_.Await(absl::Condition(&stop_)); } - void Stop() { - absl::MutexLock ml(&mu_); - stop_ = true; - } - mutable absl::Mutex mu_; bool stop_ ABSL_GUARDED_BY(mu_) = false; pid_t tid_; @@ -2190,16 +2191,18 @@ class BlockingChild { TEST(ProcTask, NewThreadAppears) { auto initial = ASSERT_NO_ERRNO_AND_VALUE(ListDir("/proc/self/task", false)); BlockingChild child1; - EXPECT_NO_ERRNO(DirContainsExactly("/proc/self/task", - TaskFiles(initial, {child1.Tid()}))); + // Use Eventually* in case a proc from ealier test is still tearing down. + EXPECT_NO_ERRNO(EventuallyDirContainsExactly( + "/proc/self/task", TaskFiles(initial, {child1.Tid()}))); } TEST(ProcTask, KilledThreadsDisappear) { auto initial = ASSERT_NO_ERRNO_AND_VALUE(ListDir("/proc/self/task/", false)); BlockingChild child1; - EXPECT_NO_ERRNO(DirContainsExactly("/proc/self/task", - TaskFiles(initial, {child1.Tid()}))); + // Use Eventually* in case a proc from ealier test is still tearing down. + EXPECT_NO_ERRNO(EventuallyDirContainsExactly( + "/proc/self/task", TaskFiles(initial, {child1.Tid()}))); // Stat child1's task file. Regression test for b/32097707. struct stat statbuf; |