| Index: test/cctest/test-lock.cc
|
| diff --git a/test/cctest/test-semaphore.cc b/test/cctest/test-lock.cc
|
| similarity index 74%
|
| rename from test/cctest/test-semaphore.cc
|
| rename to test/cctest/test-lock.cc
|
| index e06d52d2ba69715e3f6018aca986136c65bbf9da..d4387d0f906787ebf12195ad1a789448cfde5b3a 100644
|
| --- a/test/cctest/test-semaphore.cc
|
| +++ b/test/cctest/test-lock.cc
|
| @@ -1,4 +1,4 @@
|
| -// Copyright 2006-2013 the V8 project authors. All rights reserved.
|
| +// Copyright 2006-2008 the V8 project authors. All rights reserved.
|
| // Redistribution and use in source and binary forms, with or without
|
| // modification, are permitted provided that the following conditions are
|
| // met:
|
| @@ -25,7 +25,9 @@
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| //
|
| -// Tests of the Semaphore class from platform.h
|
| +// Tests of the TokenLock class from lock.h
|
| +
|
| +#include <stdlib.h>
|
|
|
| #include "v8.h"
|
|
|
| @@ -36,6 +38,33 @@
|
| using namespace ::v8::internal;
|
|
|
|
|
| +// Simple test of locking logic
|
| +TEST(Simple) {
|
| + Mutex* mutex = OS::CreateMutex();
|
| + CHECK_EQ(0, mutex->Lock()); // acquire the lock with the right token
|
| + CHECK_EQ(0, mutex->Unlock()); // can unlock with the right token
|
| + delete mutex;
|
| +}
|
| +
|
| +
|
| +TEST(MultiLock) {
|
| + Mutex* mutex = OS::CreateMutex();
|
| + CHECK_EQ(0, mutex->Lock());
|
| + CHECK_EQ(0, mutex->Unlock());
|
| + delete mutex;
|
| +}
|
| +
|
| +
|
| +TEST(ShallowLock) {
|
| + Mutex* mutex = OS::CreateMutex();
|
| + CHECK_EQ(0, mutex->Lock());
|
| + CHECK_EQ(0, mutex->Unlock());
|
| + CHECK_EQ(0, mutex->Lock());
|
| + CHECK_EQ(0, mutex->Unlock());
|
| + delete mutex;
|
| +}
|
| +
|
| +
|
| TEST(SemaphoreTimeout) {
|
| bool ok;
|
| Semaphore* sem = OS::CreateSemaphore(0);
|
|
|