/[svn]/linuxsampler/branches/release1_0_0/src/testcases/MutexTest.h
ViewVC logotype

Contents of /linuxsampler/branches/release1_0_0/src/testcases/MutexTest.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1958 - (show annotations) (download) (as text)
Fri Jul 31 08:09:09 2009 UTC (14 years, 9 months ago) by (unknown author)
File MIME type: text/x-c++hdr
File size: 1776 byte(s)
This commit was manufactured by cvs2svn to create branch 'release1_0_0'.
1 #ifndef __LS_MUTEXTEST_H__
2 #define __LS_MUTEXTEST_H__
3
4 #include <cppunit/TestFixture.h>
5 #include <cppunit/extensions/HelperMacros.h>
6
7 // needed for sleep() and usleep() calls
8 #include <unistd.h>
9
10 // the Mutex class we want to test
11 #include "../common/Mutex.h"
12
13 // we need an additional thread to test the Mutex class
14 #include "../common/Thread.h"
15
16 using namespace LinuxSampler;
17
18 class MutexTest : public CppUnit::TestFixture {
19
20 CPPUNIT_TEST_SUITE(MutexTest);
21 CPPUNIT_TEST(printTestSuiteName);
22 CPPUNIT_TEST(testLockAndUnlockBySingleThread);
23 CPPUNIT_TEST(testLock);
24 CPPUNIT_TEST(testUnlock);
25 CPPUNIT_TEST(testDoubleLock);
26 CPPUNIT_TEST(testDoubleLockStillBlocksConcurrentThread);
27 CPPUNIT_TEST_SUITE_END();
28
29 private:
30 // dummy thread to simulate usage of a shared resource
31 class ConcurrentThread : public Thread {
32 public:
33 int resource;
34 Mutex mutex;
35
36 ConcurrentThread();
37 int Main();
38 };
39
40 // 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
41 class DummyThread : public Thread {
42 public:
43 int resource;
44
45 DummyThread();
46 int Main();
47 private:
48 Mutex mutex;
49 };
50
51 bool doubleLockSucceeded; // true if testDoubleLock() was successful
52 public:
53 void setUp();
54 void tearDown();
55
56 void printTestSuiteName();
57
58 void testLockAndUnlockBySingleThread();
59 void testLock();
60 void testUnlock();
61 void testDoubleLock();
62 void testDoubleLockStillBlocksConcurrentThread();
63 };
64
65 #endif // __LS_MUTEXTEST_H__

  ViewVC Help
Powered by ViewVC