v8/test/cctest/test-lock.cc
christian.plesner.hansen@gmail.com 9bed566bdb Changed copyright header from google inc. to v8 project authors.
Added presubmit step to check copyright.



git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@242 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2008-09-09 20:08:45 +00:00

41 lines
809 B
C++

// Copyright 2006-2008 the V8 project authors. All rights reserved.
//
// Tests of the TokenLock class from lock.h
#include <stdlib.h>
#include "v8.h"
#include "platform.h"
#include "cctest.h"
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;
}