/[svn]/linuxsampler/trunk/src/testcases/MutexTest.cpp
ViewVC logotype

Contents of /linuxsampler/trunk/src/testcases/MutexTest.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 57 - (show annotations) (download)
Sun May 2 17:45:43 2004 UTC (19 years, 11 months ago) by schoenebeck
File size: 871 byte(s)
* src/common/Thread.cpp: method StartThread() now blocks until thread
  actually runs, mlockall() will only be applied for realtime threads
* libtoolized liblinuxsampler
* initiated automatic unit tests against the LinuxSampler codebase
  (see src/testcases): already added a couple of tests for the Thread and
  Mutex classes, you have to explicitly compile the unit tests by running
  'make testcases' (you need to have cppunit installed though) and then you
  can run the console version of the test runner by calling
  'src/testcases/linuxsamplertest'
* src/Sampler.h: added API documentation

1 #include "MutexTest.h"
2
3 #include <iostream>
4
5 CPPUNIT_TEST_SUITE_REGISTRATION(MutexTest);
6
7
8 // ConcurrentThread
9
10 MutexTest::ConcurrentThread::ConcurrentThread() : Thread(false, 0, -4) {
11 resource = 0;
12 }
13
14 int MutexTest::ConcurrentThread::Main() {
15 mutex.Lock();
16 resource++;
17 mutex.Unlock();
18 }
19
20
21 // MutexTest
22
23 void MutexTest::setUp() {
24 }
25
26 void MutexTest::tearDown() {
27 }
28
29 void MutexTest::testLockAndUnlockBySingleThread() {
30 ConcurrentThread t;
31 t.StartThread();
32 usleep(200000); // wait 200ms
33 CPPUNIT_ASSERT(t.resource == 1);
34 }
35
36 void MutexTest::testLock() {
37 ConcurrentThread t;
38 t.mutex.Lock();
39 t.SignalStartThread();
40 usleep(400000); // wait 400ms
41 CPPUNIT_ASSERT(t.resource == 0);
42 t.mutex.Unlock();
43 }
44
45 void MutexTest::testUnlock() {
46 CPPUNIT_ASSERT(true);
47 }
48
49 void MutexTest::testDoubleLock() {
50 CPPUNIT_ASSERT(true);
51 }

  ViewVC Help
Powered by ViewVC