/[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 3548 - (hide 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: 2632 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 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 schoenebeck 1221 public:
28 schoenebeck 57 // this is our test implementation of the abstract base class Thread which we will use to test class Thread
29 schoenebeck 1221 class DummyThread : public LinuxSampler::Thread {
30 schoenebeck 57 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 1221 volatile 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 schoenebeck 1221 };
37 schoenebeck 57
38 schoenebeck 1221 private:
39 schoenebeck 57 // this is only a helper thread to avoid that the entire test case run hangs when we try to stop the dummy thread
40 schoenebeck 1221 class HelperThread : public LinuxSampler::Thread {
41 schoenebeck 57 private:
42     DummyThread* pDummyThread;
43     public:
44     bool returnedFromDummyStop;
45    
46     HelperThread(DummyThread* pDummyThread);
47     int Main();
48 schoenebeck 211 bool dummyThreadWasNotRunningAnymoreAfter_StopThread_call();
49 schoenebeck 57 };
50 schoenebeck 63
51     // this simulates a thread that is waiting for a condition (thus sleeping til then)
52 schoenebeck 1221 class WaitingThread : public LinuxSampler::Thread {
53 schoenebeck 63 public:
54     WaitingThread();
55     int Main();
56 schoenebeck 3548 using Thread::SignalStartThread; // make method public
57 schoenebeck 63 private:
58 schoenebeck 1221 LinuxSampler::Condition condition;
59 schoenebeck 63 };
60 schoenebeck 57 public:
61     void setUp() {
62     }
63    
64     void tearDown() {
65     }
66    
67 schoenebeck 211 void printTestSuiteName();
68    
69 schoenebeck 57 void testThreadRunning();
70     void testSignalStopThread();
71     void testRelaunchThread();
72     void testStopThread();
73 schoenebeck 63 void testThreadKillableWhenWaiting();
74 schoenebeck 57 };
75    
76     #endif // __LS_THREADTEST_H__

  ViewVC Help
Powered by ViewVC