From 8df0e1ad0ac99dc754d5281ba80bb1837852ace0 Mon Sep 17 00:00:00 2001 From: Kongqun Yang Date: Mon, 21 Apr 2014 13:56:48 -0700 Subject: [PATCH] Fix flaky MultiThreadProducerConsumerQueueStopTest The main thread may run ahead of the closure thread. In this case, Stop() could have been called before the first Push() call. Change-Id: Ib6d94d451a8215fff572ea13f9567ba786d77fa5 --- media/base/producer_consumer_queue_unittest.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/media/base/producer_consumer_queue_unittest.cc b/media/base/producer_consumer_queue_unittest.cc index 6a79280add..d27fcd9feb 100644 --- a/media/base/producer_consumer_queue_unittest.cc +++ b/media/base/producer_consumer_queue_unittest.cc @@ -311,8 +311,12 @@ class MultiThreadProducerConsumerQueueStopTest int val = 0; switch (op) { case kPush: - CHECK_OK(queue_.Push(0, kInfiniteTimeout)); + // The queue was setup with size 1. The first push will return STOPPED + // if Stop() has been called; otherwise it should return OK and the + // second push will block until Stop() being called. status_ = queue_.Push(0, kInfiniteTimeout); + if (status_.ok()) + status_ = queue_.Push(0, kInfiniteTimeout); break; case kPop: status_ = queue_.Pop(&val, kInfiniteTimeout);