20 |
CPPUNIT_TEST(testLock); |
CPPUNIT_TEST(testLock); |
21 |
CPPUNIT_TEST(testUnlock); |
CPPUNIT_TEST(testUnlock); |
22 |
CPPUNIT_TEST(testDoubleLock); |
CPPUNIT_TEST(testDoubleLock); |
23 |
|
CPPUNIT_TEST(testDoubleLockStillBlocksConcurrentThread); |
24 |
CPPUNIT_TEST_SUITE_END(); |
CPPUNIT_TEST_SUITE_END(); |
25 |
|
|
26 |
private: |
private: |
27 |
|
// dummy thread to simulate usage of a shared resource |
28 |
class ConcurrentThread : public Thread { |
class ConcurrentThread : public Thread { |
29 |
public: |
public: |
30 |
int resource; |
int resource; |
33 |
ConcurrentThread(); |
ConcurrentThread(); |
34 |
int Main(); |
int Main(); |
35 |
}; |
}; |
36 |
|
|
37 |
|
// dummy thread we use to check if the Mutex falsely blcoks if we do a double lock and to avoid that our unit test main thread gets blocked |
38 |
|
class DummyThread : public Thread { |
39 |
|
public: |
40 |
|
int resource; |
41 |
|
|
42 |
|
DummyThread(); |
43 |
|
int Main(); |
44 |
|
private: |
45 |
|
Mutex mutex; |
46 |
|
}; |
47 |
|
|
48 |
|
bool doubleLockSucceeded; // true if testDoubleLock() was successful |
49 |
public: |
public: |
50 |
void setUp(); |
void setUp(); |
51 |
void tearDown(); |
void tearDown(); |
54 |
void testLock(); |
void testLock(); |
55 |
void testUnlock(); |
void testUnlock(); |
56 |
void testDoubleLock(); |
void testDoubleLock(); |
57 |
|
void testDoubleLockStillBlocksConcurrentThread(); |
58 |
}; |
}; |
59 |
|
|
60 |
#endif // __LS_MUTEXTEST_H__ |
#endif // __LS_MUTEXTEST_H__ |