Big CppUnit Update

+ Initial threaded test support
+ Integrated CppUnitShell code into TestShell


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@77 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Tyler Dauwalder
2002-07-11 03:31:07 +00:00
parent e5c292c0c9
commit 03aa30ce94
5 changed files with 327 additions and 38 deletions
+59
View File
@@ -0,0 +1,59 @@
#include <ThreadedTestCase.h>
#include <SafetyLock.h>
BThreadedTestCase::BThreadedTestCase(std::string name, std::string progressSeparator)
: BTestCase(name)
, fProgressSeparator(progressSeparator)
, fNumberMapLock(new BLocker())
{
}
BThreadedTestCase::~BThreadedTestCase() {
// Kill our locker
delete fNumberMapLock;
// Clean up
for (std::map<thread_id, ThreadSubTestInfo*>::iterator i = fNumberMap.begin();
i != fNumberMap.end();
i++)
{
delete i->second;
}
}
void
BThreadedTestCase::NextSubTest() {
// Find out what thread we're in
thread_id id = find_thread(NULL);
{
// Lock the number map
SafetyLock lock(fNumberMapLock);
std::map<thread_id, ThreadSubTestInfo*>::iterator i = fNumberMap.find(id);
if (i != fNumberMap.end() && i->second) {
// Handle multi-threaded case
ThreadSubTestInfo *info = i->second;
cout << "[" << info->subTestNum++ << fProgressSeparator << info->name << "]";
return;
}
}
// Handle single-threaded case
BTestCase::NextSubTest();
}
void
BThreadedTestCase::InitThreadInfo(thread_id id, std::string threadName) {
SafetyLock lock(fNumberMapLock); // Lock the number map
std::map<thread_id, ThreadSubTestInfo*>::iterator i = fNumberMap.find(id);
if (i != fNumberMap.end() && i->second) {
i->second->name = threadName;
i->second->subTestNum = 0;
} else {
// New addition
ThreadSubTestInfo *info = new ThreadSubTestInfo();
info->name = threadName;
info->subTestNum = 0;
fNumberMap[id] = info;
}
}