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:
|
2009-05-02 23:04:52 +04:00
|
|
|
BThreadedTestCase(std::string Name = "", std::string progressSeparator = ".");
|
2002-07-11 07:28:37 +04:00
|
|
|
virtual ~BThreadedTestCase();
|
2009-05-02 23:04:52 +04:00
|
|
|
|
2002-07-11 07:28:37 +04: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();
|
2009-05-02 23:04:52 +04:00
|
|
|
|
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.
|
2009-05-02 23:04:52 +04:00
|
|
|
|
2002-07-17 14:50:55 +04: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, ...);
|
2009-05-02 23:04:52 +04:00
|
|
|
|
|
|
|
//! Saves the location of the current working directory.
|
2002-07-11 07:28:37 +04:00
|
|
|
void SaveCWD();
|
2009-05-02 23:04:52 +04:00
|
|
|
|
|
|
|
//! Restores the current working directory to last directory saved by a call to SaveCWD().
|
2002-07-11 07:28:37 +04:00
|
|
|
void RestoreCWD(const char *alternate = NULL);
|
2009-05-02 23:04:52 +04:00
|
|
|
void InitThreadInfo(thread_id id, std::string threadName);
|
2002-07-13 00:30:45 +04:00
|
|
|
bool RegisterForUse();
|
|
|
|
void UnregisterForUse();
|
2009-05-02 23:04:52 +04:00
|
|
|
|
|
|
|
std::vector<std::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>;
|
2009-05-02 23:04:52 +04:00
|
|
|
std::string fProgressSeparator;
|
2002-07-11 07:28:37 +04:00
|
|
|
|
|
|
|
struct ThreadSubTestInfo {
|
2009-05-02 23:04:52 +04:00
|
|
|
std::string name;
|
|
|
|
int32 subTestNum;
|
2002-07-11 07:28:37 +04:00
|
|
|
};
|
2009-05-02 23:04:52 +04:00
|
|
|
std::map<thread_id, ThreadSubTestInfo*> fNumberMap;
|
|
|
|
std::vector<std::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_
|