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

Annotation of /linuxsampler/trunk/src/testcases/ThreadTest.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 211 - (hide 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: 2497 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 schoenebeck 57 #ifndef __LS_THREADTEST_H__
2     #define __LS_THREADTEST_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 Thread class we want to test
11     #include "../common/Thread.h"
12    
13 schoenebeck 63 // we need that to check if our thread is killable even if waiting for a condition
14     #include "../common/Condition.h"
15    
16 schoenebeck 57 class ThreadTest : public CppUnit::TestFixture {
17    
18     CPPUNIT_TEST_SUITE(ThreadTest);
19 schoenebeck 211 CPPUNIT_TEST(printTestSuiteName);
20 schoenebeck 57 CPPUNIT_TEST(testThreadRunning);
21     CPPUNIT_TEST(testSignalStopThread);
22     CPPUNIT_TEST(testRelaunchThread);
23     CPPUNIT_TEST(testStopThread);
24 schoenebeck 63 CPPUNIT_TEST(testThreadKillableWhenWaiting);
25 schoenebeck 57 CPPUNIT_TEST_SUITE_END();
26    
27     private:
28     // this is our test implementation of the abstract base class Thread which we will use to test class Thread
29     class DummyThread : public Thread {
30     public:
31     bool wasRunning; // this variable is false on startup and will be switched to true by the thread, so we can check if the thread actually runs
32 schoenebeck 211 int someVariable; // we constantly set this variable to -1 in the DummyThread Main() loop, so we can check in our main test thread if the DummyThread is still running by changing that value to something else than -1
33 schoenebeck 57
34     DummyThread();
35     int Main();
36     } dummythread;
37    
38     // this is only a helper thread to avoid that the entire test case run hangs when we try to stop the dummy thread
39     class HelperThread : public Thread {
40     private:
41     DummyThread* pDummyThread;
42     public:
43     bool returnedFromDummyStop;
44    
45     HelperThread(DummyThread* pDummyThread);
46     int Main();
47 schoenebeck 211 bool dummyThreadWasNotRunningAnymoreAfter_StopThread_call();
48 schoenebeck 57 };
49 schoenebeck 63
50     // this simulates a thread that is waiting for a condition (thus sleeping til then)
51     class WaitingThread : public Thread {
52     public:
53     WaitingThread();
54     int Main();
55     private:
56     Condition condition;
57     };
58 schoenebeck 57 public:
59     void setUp() {
60     }
61    
62     void tearDown() {
63     }
64    
65 schoenebeck 211 void printTestSuiteName();
66    
67 schoenebeck 57 void testThreadRunning();
68     void testSignalStopThread();
69     void testRelaunchThread();
70     void testStopThread();
71 schoenebeck 63 void testThreadKillableWhenWaiting();
72 schoenebeck 57 };
73    
74     #endif // __LS_THREADTEST_H__

  ViewVC Help
Powered by ViewVC