/[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 211 - (show annotations) (download) (as text)
Sun Jul 25 23:27:41 2004 UTC (19 years, 9 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 2115 byte(s)
* src/linuxsampler.cpp: tidied up a bit, "initialization completed"
  message shown only after the server is actually running
* src/testcases/: print the name of each test suite before running the
  tests of the suite, added first tests against the LSCP server using a
  socket connection to the LSCP server (tests for the following LSCP
  commands: "ADD CHANNEL", "GET CHANNELS", "REMOVE CHANNEL")

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

  ViewVC Help
Powered by ViewVC