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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 57 - (show annotations) (download) (as text)
Sun May 2 17:45:43 2004 UTC (19 years, 11 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 1612 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 #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 class ThreadTest : public CppUnit::TestFixture {
14
15 CPPUNIT_TEST_SUITE(ThreadTest);
16 CPPUNIT_TEST(testThreadRunning);
17 CPPUNIT_TEST(testSignalStopThread);
18 CPPUNIT_TEST(testRelaunchThread);
19 CPPUNIT_TEST(testStopThread);
20 CPPUNIT_TEST_SUITE_END();
21
22 private:
23 // this is our test implementation of the abstract base class Thread which we will use to test class Thread
24 class DummyThread : public Thread {
25 public:
26 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
27
28 DummyThread();
29 int Main();
30 } dummythread;
31
32 // this is only a helper thread to avoid that the entire test case run hangs when we try to stop the dummy thread
33 class HelperThread : public Thread {
34 private:
35 DummyThread* pDummyThread;
36 public:
37 bool returnedFromDummyStop;
38
39 HelperThread(DummyThread* pDummyThread);
40 int Main();
41 };
42 public:
43 void setUp() {
44 }
45
46 void tearDown() {
47 }
48
49 void testThreadRunning();
50 void testSignalStopThread();
51 void testRelaunchThread();
52 void testStopThread();
53 };
54
55 #endif // __LS_THREADTEST_H__

  ViewVC Help
Powered by ViewVC