Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 1 | #include "aos/common/condition.h" |
| 2 | |
| 3 | #include <unistd.h> |
| 4 | #include <sys/types.h> |
| 5 | #include <sys/wait.h> |
| 6 | |
Brian Silverman | f119464 | 2014-09-04 13:01:17 -0400 | [diff] [blame] | 7 | #include <atomic> |
| 8 | |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 9 | #include "gtest/gtest.h" |
| 10 | |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 11 | #include "aos/common/time.h" |
| 12 | #include "aos/common/mutex.h" |
| 13 | #include "aos/common/queue_testutils.h" |
| 14 | #include "aos/common/type_traits.h" |
Brian Silverman | 14fd0fb | 2014-01-14 21:42:01 -0800 | [diff] [blame] | 15 | #include "aos/linux_code/ipc_lib/core_lib.h" |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 16 | #include "aos/common/logging/logging.h" |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 17 | #include "aos/common/macros.h" |
Brian Silverman | dc1eb27 | 2014-08-19 14:25:59 -0400 | [diff] [blame^] | 18 | #include "aos/linux_code/ipc_lib/aos_sync.h" |
Brian Silverman | 8d2e56e | 2013-09-23 17:55:03 -0700 | [diff] [blame] | 19 | #include "aos/common/die.h" |
Brian Silverman | f119464 | 2014-09-04 13:01:17 -0400 | [diff] [blame] | 20 | #include "aos/common/util/thread.h" |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 21 | |
| 22 | using ::aos::time::Time; |
| 23 | using ::aos::common::testing::GlobalCoreInstance; |
| 24 | |
| 25 | namespace aos { |
| 26 | namespace testing { |
| 27 | |
Brian Silverman | f119464 | 2014-09-04 13:01:17 -0400 | [diff] [blame] | 28 | class ConditionTestCommon : public ::testing::Test { |
| 29 | public: |
| 30 | ConditionTestCommon() {} |
| 31 | |
| 32 | void Settle() { |
| 33 | time::SleepFor(::Time::InSeconds(0.008)); |
| 34 | } |
| 35 | |
| 36 | private: |
| 37 | DISALLOW_COPY_AND_ASSIGN(ConditionTestCommon); |
| 38 | }; |
| 39 | |
| 40 | // Some simple tests that don't rely on a GlobalCoreInstance to help with |
| 41 | // debugging problems that cause tests using that to just completely lock up. |
| 42 | class SimpleConditionTest : public ConditionTestCommon { |
| 43 | public: |
| 44 | SimpleConditionTest() : condition_(&mutex_) {} |
| 45 | |
| 46 | Mutex mutex_; |
| 47 | Condition condition_; |
| 48 | |
| 49 | private: |
| 50 | DISALLOW_COPY_AND_ASSIGN(SimpleConditionTest); |
| 51 | }; |
| 52 | |
| 53 | // Makes sure that nothing crashes or anything with a basic Wait() and then |
| 54 | // Signal(). |
| 55 | // This test is written to hopefully fail instead of deadlocking on failure, but |
| 56 | // it's tricky because there's no way to kill the child in the middle. |
| 57 | TEST_F(SimpleConditionTest, Basic) { |
| 58 | ::std::atomic_bool child_finished(false); |
| 59 | Condition child_ready(&mutex_); |
| 60 | ASSERT_FALSE(mutex_.Lock()); |
| 61 | util::FunctionThread child([this, &child_finished, &child_ready]( |
| 62 | util::FunctionThread *) { |
| 63 | ASSERT_FALSE(mutex_.Lock()); |
| 64 | child_ready.Broadcast(); |
| 65 | ASSERT_FALSE(condition_.Wait()); |
| 66 | child_finished.store(true); |
| 67 | mutex_.Unlock(); |
| 68 | }); |
| 69 | child.Start(); |
| 70 | ASSERT_FALSE(child_ready.Wait()); |
| 71 | EXPECT_FALSE(child_finished.load()); |
| 72 | condition_.Signal(); |
| 73 | mutex_.Unlock(); |
| 74 | child.Join(); |
| 75 | EXPECT_TRUE(child_finished.load()); |
| 76 | } |
| 77 | |
| 78 | class ConditionTest : public ConditionTestCommon { |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 79 | public: |
| 80 | struct Shared { |
| 81 | Shared() : condition(&mutex) {} |
| 82 | |
| 83 | Mutex mutex; |
| 84 | Condition condition; |
| 85 | }; |
| 86 | static_assert(shm_ok<Shared>::value, |
| 87 | "it's going to get shared between forked processes"); |
| 88 | |
| 89 | ConditionTest() : shared_(static_cast<Shared *>(shm_malloc(sizeof(Shared)))) { |
| 90 | new (shared_) Shared(); |
| 91 | } |
Brian Silverman | dc1eb27 | 2014-08-19 14:25:59 -0400 | [diff] [blame^] | 92 | ~ConditionTest() { |
| 93 | shared_->~Shared(); |
| 94 | } |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 95 | |
| 96 | GlobalCoreInstance my_core; |
| 97 | |
| 98 | Shared *const shared_; |
| 99 | |
Brian Silverman | 8d2e56e | 2013-09-23 17:55:03 -0700 | [diff] [blame] | 100 | protected: |
| 101 | void SetUp() override { |
| 102 | SetDieTestMode(true); |
| 103 | } |
| 104 | |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 105 | private: |
| 106 | DISALLOW_COPY_AND_ASSIGN(ConditionTest); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 107 | }; |
| 108 | |
| 109 | class ConditionTestProcess { |
| 110 | public: |
| 111 | enum class Action { |
| 112 | kWaitLockStart, // lock, delay, wait, unlock |
| 113 | kWait, // delay, lock, wait, unlock |
| 114 | kWaitNoUnlock, // delay, lock, wait |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 115 | }; |
| 116 | |
| 117 | // This amount gets added to any passed in delay to make the test repeatable. |
Brian Silverman | dc1eb27 | 2014-08-19 14:25:59 -0400 | [diff] [blame^] | 118 | static constexpr ::Time kMinimumDelay = ::Time::InSeconds(0.15); |
| 119 | static constexpr ::Time kDefaultTimeout = ::Time::InSeconds(0.15); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 120 | |
| 121 | // delay is how long to wait before doing action to condition. |
| 122 | // timeout is how long to wait after delay before deciding that it's hung. |
| 123 | ConditionTestProcess(const ::Time &delay, Action action, Condition *condition, |
| 124 | const ::Time &timeout = kDefaultTimeout) |
| 125 | : delay_(kMinimumDelay + delay), action_(action), condition_(condition), |
| 126 | timeout_(delay_ + timeout), child_(-1), |
| 127 | shared_(static_cast<Shared *>(shm_malloc(sizeof(Shared)))) { |
| 128 | new (shared_) Shared(); |
| 129 | } |
| 130 | ~ConditionTestProcess() { |
Brian Silverman | fe457de | 2014-05-26 22:04:08 -0700 | [diff] [blame] | 131 | CHECK_EQ(child_, -1); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | void Start() { |
| 135 | ASSERT_FALSE(shared_->started); |
| 136 | |
| 137 | child_ = fork(); |
| 138 | if (child_ == 0) { // in child |
Brian Silverman | eeb62ca | 2013-09-11 15:08:03 -0700 | [diff] [blame] | 139 | ::aos::common::testing::PreventExit(); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 140 | Run(); |
| 141 | exit(EXIT_SUCCESS); |
| 142 | } else { // in parent |
Brian Silverman | fe457de | 2014-05-26 22:04:08 -0700 | [diff] [blame] | 143 | CHECK_NE(child_, -1); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 144 | |
Brian Silverman | dc1eb27 | 2014-08-19 14:25:59 -0400 | [diff] [blame^] | 145 | ASSERT_EQ(0, futex_wait(&shared_->ready)); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 146 | |
| 147 | shared_->started = true; |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | bool IsFinished() { |
| 152 | return shared_->finished; |
| 153 | } |
| 154 | |
| 155 | ::testing::AssertionResult Hung() { |
| 156 | if (!shared_->started) { |
| 157 | ADD_FAILURE(); |
| 158 | return ::testing::AssertionFailure() << "not started yet"; |
| 159 | } |
| 160 | if (shared_->finished) { |
| 161 | Join(); |
| 162 | return ::testing::AssertionFailure() << "already returned"; |
| 163 | } |
| 164 | if (shared_->delayed) { |
| 165 | if (shared_->start_time > ::Time::Now() + timeout_) { |
| 166 | Kill(); |
| 167 | return ::testing::AssertionSuccess() << "already been too long"; |
| 168 | } |
| 169 | } else { |
Brian Silverman | dc1eb27 | 2014-08-19 14:25:59 -0400 | [diff] [blame^] | 170 | CHECK_EQ(0, futex_wait(&shared_->done_delaying)); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 171 | } |
| 172 | time::SleepFor(::Time::InSeconds(0.01)); |
| 173 | if (!shared_->finished) time::SleepUntil(shared_->start_time + timeout_); |
| 174 | if (shared_->finished) { |
| 175 | Join(); |
| 176 | return ::testing::AssertionFailure() << "completed within timeout"; |
| 177 | } else { |
| 178 | Kill(); |
| 179 | return ::testing::AssertionSuccess() << "took too long"; |
| 180 | } |
| 181 | } |
| 182 | ::testing::AssertionResult Test() { |
| 183 | Start(); |
| 184 | return Hung(); |
| 185 | } |
| 186 | |
| 187 | private: |
| 188 | struct Shared { |
| 189 | Shared() |
Brian Silverman | dc1eb27 | 2014-08-19 14:25:59 -0400 | [diff] [blame^] | 190 | : started(false), delayed(false), done_delaying(0), start_time(0, 0), |
| 191 | finished(false), ready(0) { |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 192 | } |
| 193 | |
Brian Silverman | eeb62ca | 2013-09-11 15:08:03 -0700 | [diff] [blame] | 194 | volatile bool started; |
| 195 | volatile bool delayed; |
Brian Silverman | dc1eb27 | 2014-08-19 14:25:59 -0400 | [diff] [blame^] | 196 | aos_futex done_delaying; |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 197 | ::Time start_time; |
Brian Silverman | eeb62ca | 2013-09-11 15:08:03 -0700 | [diff] [blame] | 198 | volatile bool finished; |
Brian Silverman | dc1eb27 | 2014-08-19 14:25:59 -0400 | [diff] [blame^] | 199 | aos_futex ready; |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 200 | }; |
| 201 | static_assert(shm_ok<Shared>::value, |
| 202 | "it's going to get shared between forked processes"); |
| 203 | |
| 204 | void Run() { |
| 205 | if (action_ == Action::kWaitLockStart) { |
Brian Silverman | dc1eb27 | 2014-08-19 14:25:59 -0400 | [diff] [blame^] | 206 | ASSERT_EQ(1, futex_set(&shared_->ready)); |
| 207 | ASSERT_FALSE(condition_->m()->Lock()); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 208 | } |
| 209 | time::SleepFor(delay_); |
| 210 | shared_->start_time = ::Time::Now(); |
| 211 | shared_->delayed = true; |
Brian Silverman | dc1eb27 | 2014-08-19 14:25:59 -0400 | [diff] [blame^] | 212 | ASSERT_NE(-1, futex_set(&shared_->done_delaying)); |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 213 | if (action_ != Action::kWaitLockStart) { |
Brian Silverman | dc1eb27 | 2014-08-19 14:25:59 -0400 | [diff] [blame^] | 214 | ASSERT_EQ(1, futex_set(&shared_->ready)); |
| 215 | ASSERT_FALSE(condition_->m()->Lock()); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 216 | } |
Brian Silverman | dc1eb27 | 2014-08-19 14:25:59 -0400 | [diff] [blame^] | 217 | // TODO(brians): Test this returning true (aka the owner dying). |
| 218 | ASSERT_FALSE(condition_->Wait()); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 219 | shared_->finished = true; |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 220 | if (action_ != Action::kWaitNoUnlock) { |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 221 | condition_->m()->Unlock(); |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | void Join() { |
Brian Silverman | fe457de | 2014-05-26 22:04:08 -0700 | [diff] [blame] | 226 | CHECK_NE(child_, -1); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 227 | int status; |
| 228 | do { |
Brian Silverman | fe457de | 2014-05-26 22:04:08 -0700 | [diff] [blame] | 229 | CHECK_EQ(waitpid(child_, &status, 0), child_); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 230 | } while (!(WIFEXITED(status) || WIFSIGNALED(status))); |
| 231 | child_ = -1; |
| 232 | } |
| 233 | void Kill() { |
Brian Silverman | fe457de | 2014-05-26 22:04:08 -0700 | [diff] [blame] | 234 | CHECK_NE(child_, -1); |
| 235 | PCHECK(kill(child_, SIGTERM)); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 236 | Join(); |
| 237 | } |
| 238 | |
| 239 | const ::Time delay_; |
| 240 | const Action action_; |
| 241 | Condition *const condition_; |
| 242 | const ::Time timeout_; |
| 243 | |
| 244 | pid_t child_; |
| 245 | |
| 246 | Shared *const shared_; |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 247 | |
| 248 | DISALLOW_COPY_AND_ASSIGN(ConditionTestProcess); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 249 | }; |
| 250 | constexpr ::Time ConditionTestProcess::kMinimumDelay; |
| 251 | constexpr ::Time ConditionTestProcess::kDefaultTimeout; |
| 252 | |
| 253 | // Makes sure that the testing framework and everything work for a really simple |
| 254 | // Wait() and then Signal(). |
| 255 | TEST_F(ConditionTest, Basic) { |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 256 | ConditionTestProcess child(::Time(0, 0), |
| 257 | ConditionTestProcess::Action::kWait, |
| 258 | &shared_->condition); |
| 259 | child.Start(); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 260 | Settle(); |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 261 | EXPECT_FALSE(child.IsFinished()); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 262 | shared_->condition.Signal(); |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 263 | EXPECT_FALSE(child.Hung()); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 264 | } |
| 265 | |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 266 | // Makes sure that the worker child locks before it tries to Wait() etc. |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 267 | TEST_F(ConditionTest, Locking) { |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 268 | ConditionTestProcess child(::Time(0, 0), |
| 269 | ConditionTestProcess::Action::kWait, |
| 270 | &shared_->condition); |
Brian Silverman | dc1eb27 | 2014-08-19 14:25:59 -0400 | [diff] [blame^] | 271 | ASSERT_FALSE(shared_->mutex.Lock()); |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 272 | child.Start(); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 273 | Settle(); |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 274 | // This Signal() shouldn't do anything because the child should still be |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 275 | // waiting to lock the mutex. |
| 276 | shared_->condition.Signal(); |
| 277 | Settle(); |
| 278 | shared_->mutex.Unlock(); |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 279 | EXPECT_TRUE(child.Hung()); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 280 | } |
| 281 | |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 282 | // Tests that the work child only catches a Signal() after the mutex gets |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 283 | // unlocked. |
| 284 | TEST_F(ConditionTest, LockFirst) { |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 285 | ConditionTestProcess child(::Time(0, 0), |
| 286 | ConditionTestProcess::Action::kWait, |
| 287 | &shared_->condition); |
Brian Silverman | dc1eb27 | 2014-08-19 14:25:59 -0400 | [diff] [blame^] | 288 | ASSERT_FALSE(shared_->mutex.Lock()); |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 289 | child.Start(); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 290 | Settle(); |
| 291 | shared_->condition.Signal(); |
| 292 | Settle(); |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 293 | EXPECT_FALSE(child.IsFinished()); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 294 | shared_->mutex.Unlock(); |
| 295 | Settle(); |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 296 | EXPECT_FALSE(child.IsFinished()); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 297 | shared_->condition.Signal(); |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 298 | EXPECT_FALSE(child.Hung()); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | // Tests that the mutex gets relocked after Wait() returns. |
| 302 | TEST_F(ConditionTest, Relocking) { |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 303 | ConditionTestProcess child(::Time(0, 0), |
| 304 | ConditionTestProcess::Action::kWaitNoUnlock, |
| 305 | &shared_->condition); |
| 306 | child.Start(); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 307 | Settle(); |
| 308 | shared_->condition.Signal(); |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 309 | EXPECT_FALSE(child.Hung()); |
Brian Silverman | dc1eb27 | 2014-08-19 14:25:59 -0400 | [diff] [blame^] | 310 | EXPECT_EQ(Mutex::State::kUnlocked, shared_->mutex.TryLock()); |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 311 | } |
| 312 | |
Brian Silverman | 2586a5d | 2013-09-13 13:45:52 -0700 | [diff] [blame] | 313 | // Tests that Signal() stops exactly 1 Wait()er. |
| 314 | TEST_F(ConditionTest, SignalOne) { |
| 315 | ConditionTestProcess child1(::Time(0, 0), |
| 316 | ConditionTestProcess::Action::kWait, |
| 317 | &shared_->condition); |
| 318 | ConditionTestProcess child2(::Time(0, 0), |
| 319 | ConditionTestProcess::Action::kWait, |
| 320 | &shared_->condition); |
| 321 | ConditionTestProcess child3(::Time(0, 0), |
| 322 | ConditionTestProcess::Action::kWait, |
| 323 | &shared_->condition); |
| 324 | auto number_finished = [&]() { return (child1.IsFinished() ? 1 : 0) + |
| 325 | (child2.IsFinished() ? 1 : 0) + (child3.IsFinished() ? 1 : 0); }; |
| 326 | child1.Start(); |
| 327 | child2.Start(); |
| 328 | child3.Start(); |
| 329 | Settle(); |
| 330 | EXPECT_EQ(0, number_finished()); |
| 331 | shared_->condition.Signal(); |
| 332 | Settle(); |
| 333 | EXPECT_EQ(1, number_finished()); |
| 334 | shared_->condition.Signal(); |
| 335 | Settle(); |
| 336 | EXPECT_EQ(2, number_finished()); |
| 337 | shared_->condition.Signal(); |
| 338 | Settle(); |
| 339 | EXPECT_EQ(3, number_finished()); |
| 340 | EXPECT_FALSE(child1.Hung()); |
| 341 | EXPECT_FALSE(child2.Hung()); |
| 342 | EXPECT_FALSE(child3.Hung()); |
| 343 | } |
| 344 | |
| 345 | // Tests that Brodcast() wakes multiple Wait()ers. |
| 346 | TEST_F(ConditionTest, Broadcast) { |
| 347 | ConditionTestProcess child1(::Time(0, 0), |
| 348 | ConditionTestProcess::Action::kWait, |
| 349 | &shared_->condition); |
| 350 | ConditionTestProcess child2(::Time(0, 0), |
| 351 | ConditionTestProcess::Action::kWait, |
| 352 | &shared_->condition); |
| 353 | ConditionTestProcess child3(::Time(0, 0), |
| 354 | ConditionTestProcess::Action::kWait, |
| 355 | &shared_->condition); |
| 356 | child1.Start(); |
| 357 | child2.Start(); |
| 358 | child3.Start(); |
| 359 | Settle(); |
| 360 | shared_->condition.Broadcast(); |
| 361 | EXPECT_FALSE(child1.Hung()); |
| 362 | EXPECT_FALSE(child2.Hung()); |
| 363 | EXPECT_FALSE(child3.Hung()); |
| 364 | } |
| 365 | |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 366 | } // namespace testing |
| 367 | } // namespace aos |