Index: third_party/crashpad/crashpad/util/thread/worker_thread_test.cc |
diff --git a/third_party/crashpad/crashpad/util/thread/worker_thread_test.cc b/third_party/crashpad/crashpad/util/thread/worker_thread_test.cc |
index 0cbee187fbcd1eef2c49b0b205abbe1784e32787..044734c84808edff5851738ed9dfc5688be79c84 100644 |
--- a/third_party/crashpad/crashpad/util/thread/worker_thread_test.cc |
+++ b/third_party/crashpad/crashpad/util/thread/worker_thread_test.cc |
@@ -30,8 +30,11 @@ class WorkDelegate : public WorkerThread::Delegate { |
~WorkDelegate() {} |
void DoWork(const WorkerThread* thread) override { |
- if (++work_count_ == waiting_for_count_) |
- semaphore_.Signal(); |
+ if (work_count_ < waiting_for_count_) { |
+ if (++work_count_ == waiting_for_count_) { |
+ semaphore_.Signal(); |
+ } |
+ } |
} |
void SetDesiredWorkCount(int times) { |
@@ -59,6 +62,7 @@ TEST(WorkerThread, DoWork) { |
WorkerThread thread(0.05, &delegate); |
uint64_t start = ClockMonotonicNanoseconds(); |
+ |
delegate.SetDesiredWorkCount(2); |
thread.Start(0); |
EXPECT_TRUE(thread.is_running()); |
@@ -103,12 +107,12 @@ TEST(WorkerThread, DoWorkNow) { |
WorkDelegate delegate; |
WorkerThread thread(100, &delegate); |
+ uint64_t start = ClockMonotonicNanoseconds(); |
+ |
delegate.SetDesiredWorkCount(1); |
thread.Start(0); |
EXPECT_TRUE(thread.is_running()); |
- uint64_t start = ClockMonotonicNanoseconds(); |
- |
delegate.WaitForWorkCount(); |
EXPECT_EQ(1, delegate.work_count()); |