/[svn]/linuxsampler/trunk/src/testcases/ConditionTest.h
ViewVC logotype

Contents of /linuxsampler/trunk/src/testcases/ConditionTest.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3548 - (show annotations) (download) (as text)
Wed Jul 31 09:35:10 2019 UTC (4 years, 8 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 2288 byte(s)
* Fixed compiler error in Pool.h.
* Fixed compiler errors in test cases.
* Updated README for how to compile & run test cases.
* Updated test case
  MutexTest::testDoubleLockStillBlocksConcurrentThread() to latest
  expected behaviour of the Mutex class implementation (recursive
  mutex type).
* Bumped version (2.1.1.svn1).

1 #ifndef __LS_CONDITIONTEST_H__
2 #define __LS_CONDITIONTEST_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 Condition class we want to test
11 #include "../common/Condition.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 ConditionTest : public CppUnit::TestFixture {
19
20 CPPUNIT_TEST_SUITE(ConditionTest);
21 CPPUNIT_TEST(printTestSuiteName);
22 CPPUNIT_TEST(testDoesntBlockOnDesiredCondtion);
23 CPPUNIT_TEST(testBlocksIfNotDesiredCondition);
24 CPPUNIT_TEST(testBlocksUntilDesiredCondition);
25 CPPUNIT_TEST(testWaitIFBlocksConcurrentThread);
26 CPPUNIT_TEST_SUITE_END();
27
28 private:
29 // simulates a thread waiting for a condition
30 class ConditionChecker : public Thread {
31 public:
32 int resource;
33 Condition condition;
34
35 ConditionChecker(bool waitFor);
36 int Main();
37 using Thread::SignalStartThread; // make method public
38 protected:
39 bool waitFor;
40 };
41
42 // simulates a thread which sets the condition
43 class ConditionSetter : public Thread {
44 public:
45 int resource;
46 Condition* condition;
47
48 ConditionSetter(Condition* condition, bool toSet);
49 int Main();
50 using Thread::SignalStartThread; // make method public
51 private:
52 bool toSet;
53 };
54
55 // same as 'ConditionChecker' except that this one uses WaitIf() instead of WaitAndUnlockIf()
56 class ConditionCheckerLocking : public ConditionChecker {
57 public:
58 bool doUnlock;
59 static Condition staticcondition;
60
61 ConditionCheckerLocking(bool waitFor);
62 int Main();
63 };
64 public:
65 void setUp();
66 void tearDown();
67
68 void printTestSuiteName();
69
70 void testDoesntBlockOnDesiredCondtion();
71 void testBlocksIfNotDesiredCondition();
72 void testBlocksUntilDesiredCondition();
73 void testWaitIFBlocksConcurrentThread();
74 };
75
76 #endif // __LS_CONDITIONTEST_H__

  ViewVC Help
Powered by ViewVC