2002-07-11 07:28:37 +04:00
|
|
|
#ifndef _beos_threaded_test_case_h_
|
|
|
|
#define _beos_threaded_test_case_h_
|
|
|
|
|
|
|
|
#include <Locker.h>
|
2002-07-18 09:32:00 +04:00
|
|
|
#include <OS.h>
|
2002-07-11 07:28:37 +04:00
|
|
|
#include <TestCase.h>
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
2002-07-13 00:30:45 +04:00
|
|
|
#include <vector>
|
2002-07-11 07:28:37 +04:00
|
|
|
|
|
|
|
//! Base class for single threaded unit tests
|
2004-02-19 00:38:04 +03:00
|
|
|
class CPPUNIT_API BThreadedTestCase : public BTestCase {
|
2002-07-11 07:28:37 +04:00
|
|
|
public:
|
2004-02-17 22:57:58 +03:00
|
|
|
BThreadedTestCase(string Name = "", string progressSeparator = ".");
|
2002-07-11 07:28:37 +04:00
|
|
|
virtual ~BThreadedTestCase();
|
|
|
|
|
|
|
|
/*! \brief Displays the next sub test progress indicator for the
|
|
|
|
thread in which it's called (i.e. [A.0][B.0][A.1][A.2][B.1]...). */
|
|
|
|
virtual void NextSubTest();
|
|
|
|
|
2002-07-17 14:50:55 +04:00
|
|
|
/*! \brief Prints to standard out just like printf, except shell verbosity
|
|
|
|
settings are honored, and output from threads other than the main thread
|
|
|
|
happens before the test is over.
|
|
|
|
|
|
|
|
\note Currently your output is limited to a length of 1024 characters. If
|
|
|
|
you really need to print a single string that's long than that, fix the
|
|
|
|
function yourself :-).
|
|
|
|
*/
|
|
|
|
virtual void Outputf(const char *str, ...);
|
|
|
|
|
2002-07-11 07:28:37 +04:00
|
|
|
//! Saves the location of the current working directory.
|
|
|
|
void SaveCWD();
|
|
|
|
|
|
|
|
//! Restores the current working directory to last directory saved by a call to SaveCWD().
|
|
|
|
void RestoreCWD(const char *alternate = NULL);
|
2004-02-17 22:57:58 +03:00
|
|
|
void InitThreadInfo(thread_id id, string threadName);
|
2002-07-13 00:30:45 +04:00
|
|
|
bool RegisterForUse();
|
|
|
|
void UnregisterForUse();
|
|
|
|
|
2004-02-17 22:57:58 +03:00
|
|
|
vector<string>& AcquireUpdateList();
|
2002-07-13 00:30:45 +04:00
|
|
|
void ReleaseUpdateList();
|
2002-07-11 07:28:37 +04:00
|
|
|
protected:
|
2002-07-13 00:30:45 +04:00
|
|
|
bool fInUse;
|
|
|
|
|
2002-07-11 07:28:37 +04:00
|
|
|
// friend class ThreadManager<BThreadedTestCase>;
|
2004-02-17 22:57:58 +03:00
|
|
|
string fProgressSeparator;
|
2002-07-11 07:28:37 +04:00
|
|
|
|
|
|
|
struct ThreadSubTestInfo {
|
2004-02-17 22:57:58 +03:00
|
|
|
string name;
|
2002-07-11 07:28:37 +04:00
|
|
|
int32 subTestNum;
|
|
|
|
};
|
2004-02-17 22:57:58 +03:00
|
|
|
map<thread_id, ThreadSubTestInfo*> fNumberMap;
|
|
|
|
vector<string> fUpdateList;
|
2002-07-13 00:30:45 +04:00
|
|
|
BLocker *fUpdateLock;
|
|
|
|
|
2002-07-11 07:28:37 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _beos_threaded_test_case_h_
|