headers/bsd: Add sys/queue.h.
[haiku.git] / headers / tools / cppunit / ThreadedTestCase.h
blob63fd219c547e8c93dad3939b52bf6e7cef0d28b1
1 #ifndef _beos_threaded_test_case_h_
2 #define _beos_threaded_test_case_h_
4 #include <Locker.h>
5 #include <OS.h>
6 #include <TestCase.h>
7 #include <map>
8 #include <string>
9 #include <vector>
11 //! Base class for single threaded unit tests
12 class CPPUNIT_API BThreadedTestCase : public BTestCase {
13 public:
14 BThreadedTestCase(std::string Name = "", std::string progressSeparator = ".");
15 virtual ~BThreadedTestCase();
17 /*! \brief Displays the next sub test progress indicator for the
18 thread in which it's called (i.e. [A.0][B.0][A.1][A.2][B.1]...). */
19 virtual void NextSubTest();
21 /*! \brief Prints to standard out just like printf, except shell verbosity
22 settings are honored, and output from threads other than the main thread
23 happens before the test is over.
25 \note Currently your output is limited to a length of 1024 characters. If
26 you really need to print a single string that's long than that, fix the
27 function yourself :-).
29 virtual void Outputf(const char *str, ...);
31 //! Saves the location of the current working directory.
32 void SaveCWD();
34 //! Restores the current working directory to last directory saved by a call to SaveCWD().
35 void RestoreCWD(const char *alternate = NULL);
36 void InitThreadInfo(thread_id id, std::string threadName);
37 bool RegisterForUse();
38 void UnregisterForUse();
40 std::vector<std::string>& AcquireUpdateList();
41 void ReleaseUpdateList();
42 protected:
43 bool fInUse;
45 // friend class ThreadManager<BThreadedTestCase>;
46 std::string fProgressSeparator;
48 struct ThreadSubTestInfo {
49 std::string name;
50 int32 subTestNum;
52 std::map<thread_id, ThreadSubTestInfo*> fNumberMap;
53 std::vector<std::string> fUpdateList;
54 BLocker *fUpdateLock;
58 #endif // _beos_threaded_test_case_h_