Index: test/cctest/test-lock.cc |
=================================================================== |
--- test/cctest/test-lock.cc (revision 1525) |
+++ test/cctest/test-lock.cc (working copy) |
@@ -38,3 +38,26 @@ |
CHECK_EQ(0, mutex->Unlock()); |
delete mutex; |
} |
+ |
+ |
+TEST(SemaphoreTimeout) { |
+ bool ok; |
+ Semaphore* sem = OS::CreateSemaphore(0); |
+ |
+ // Semaphore not signalled - timeout. |
+ ok = sem->Wait(0); |
+ CHECK(!ok); |
+ ok = sem->Wait(100); |
+ CHECK(!ok); |
+ ok = sem->Wait(1000); |
+ CHECK(!ok); |
+ |
+ // Semaphore signalled - no timeout. |
+ sem->Signal(); |
+ ok = sem->Wait(0); |
+ sem->Signal(); |
+ ok = sem->Wait(100); |
+ sem->Signal(); |
+ ok = sem->Wait(1000); |
+ CHECK(ok); |
+} |