Files
haiku-beta6/headers/tools/cppunit/ThreadedTestCase.h
T

59 lines
1.7 KiB
C++
Raw Normal View History

2002-07-11 03:28:37 +00:00
#ifndef _beos_threaded_test_case_h_
#define _beos_threaded_test_case_h_
#include <Locker.h>
#include <OS.h>
2002-07-11 03:28:37 +00:00
#include <TestCase.h>
#include <map>
#include <string>
#include <vector>
2002-07-11 03:28:37 +00:00
//! Base class for single threaded unit tests
class CPPUNIT_API BThreadedTestCase : public BTestCase {
2002-07-11 03:28:37 +00:00
public:
BThreadedTestCase(std::string Name = "", std::string progressSeparator = ".");
2002-07-11 03:28:37 +00:00
virtual ~BThreadedTestCase();
2002-07-11 03:28:37 +00:00
/*! \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 10:50:55 +00: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.
2002-07-17 10:50:55 +00:00
\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, ...);
//! Saves the location of the current working directory.
2002-07-11 03:28:37 +00:00
void SaveCWD();
//! Restores the current working directory to last directory saved by a call to SaveCWD().
2002-07-11 03:28:37 +00:00
void RestoreCWD(const char *alternate = NULL);
void InitThreadInfo(thread_id id, std::string threadName);
bool RegisterForUse();
void UnregisterForUse();
std::vector<std::string>& AcquireUpdateList();
void ReleaseUpdateList();
2002-07-11 03:28:37 +00:00
protected:
bool fInUse;
2002-07-11 03:28:37 +00:00
// friend class ThreadManager<BThreadedTestCase>;
std::string fProgressSeparator;
2002-07-11 03:28:37 +00:00
struct ThreadSubTestInfo {
std::string name;
int32 subTestNum;
2002-07-11 03:28:37 +00:00
};
std::map<thread_id, ThreadSubTestInfo*> fNumberMap;
std::vector<std::string> fUpdateList;
BLocker *fUpdateLock;
2002-07-11 03:28:37 +00:00
};
#endif // _beos_threaded_test_case_h_