2002-07-11 07:34:41 +04:00
|
|
|
#include "UnitTester.h"
|
2002-07-15 10:58:52 +04:00
|
|
|
#include <SemaphoreSyncObject.h>
|
|
|
|
#include <Directory.h>
|
2002-07-11 07:34:41 +04:00
|
|
|
|
|
|
|
// ##### Include headers for statically linked tests here #####
|
2002-07-15 10:58:52 +04:00
|
|
|
//#include <ExampleTest.h>
|
2002-07-11 07:34:41 +04:00
|
|
|
|
2002-07-15 10:58:52 +04:00
|
|
|
UnitTesterShell shell("OpenBeOS Unit Testing Framework", new SemaphoreSyncObject);
|
2002-07-11 07:34:41 +04:00
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
// ##### Add test suites for statically linked tests here #####
|
2002-07-15 10:58:52 +04:00
|
|
|
// shell.AddTest( "Example", ExampleTest::Suite() );
|
|
|
|
|
2002-07-18 05:03:19 +04:00
|
|
|
BTestShell::SetGlobalShell(&shell);
|
2002-07-15 10:58:52 +04:00
|
|
|
|
|
|
|
// Load our dynamically linked tests
|
2002-07-11 07:34:41 +04:00
|
|
|
|
|
|
|
return shell.Run(argc, argv);
|
|
|
|
}
|
|
|
|
|
2002-07-17 14:50:55 +04:00
|
|
|
const std::string UnitTesterShell::defaultLibDir = "./lib";
|
|
|
|
|
2002-07-11 07:34:41 +04:00
|
|
|
UnitTesterShell::UnitTesterShell(const std::string &description, SyncObject *syncObject)
|
|
|
|
: BTestShell(description, syncObject)
|
2002-07-17 14:50:55 +04:00
|
|
|
, doR5Tests(false)
|
2002-07-11 07:34:41 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UnitTesterShell::PrintDescription(int argc, char *argv[]) {
|
|
|
|
std::string AppName = argv[0];
|
|
|
|
cout << endl;
|
|
|
|
cout << "This program is the central testing framework for the purpose" << endl;
|
|
|
|
cout << "of testing and verifying the various kits, classes, functions," << endl;
|
|
|
|
cout << "and the like that comprise OpenBeOS." << endl;
|
|
|
|
|
2002-07-17 14:50:55 +04:00
|
|
|
/*
|
2002-07-15 10:58:52 +04:00
|
|
|
if (AppName.rfind("UnitTester_r5") != std::string::npos) {
|
2002-07-11 07:34:41 +04:00
|
|
|
cout << endl;
|
2002-07-15 10:58:52 +04:00
|
|
|
cout << "Judging by its name (UnitTester_r5), this copy was" << endl;
|
2002-07-11 07:34:41 +04:00
|
|
|
cout << "probably linked against Be Inc.'s R5 implementations" << endl;
|
|
|
|
cout << "for the sake of comparison." << endl;
|
2002-07-15 10:58:52 +04:00
|
|
|
} else if (AppName.rfind("UnitTester") != std::string::npos) {
|
2002-07-11 07:34:41 +04:00
|
|
|
cout << endl;
|
2002-07-15 10:58:52 +04:00
|
|
|
cout << "Judging by its name (UnitTester), this copy was probably" << endl;
|
|
|
|
cout << "linked against our own OpenBeOS implementations." << endl;
|
2002-07-11 07:34:41 +04:00
|
|
|
}
|
2002-07-17 14:50:55 +04:00
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
UnitTesterShell::PrintValidArguments() {
|
|
|
|
BTestShell::PrintValidArguments();
|
2002-07-19 10:45:28 +04:00
|
|
|
cout << indent << "-obos Runs tests linked against our OpenBeOS libraries (*default*)" << endl;
|
|
|
|
cout << indent << "-r5 Runs tests linked against Be Inc.'s R5 libraries (instead" << endl;
|
|
|
|
cout << indent << " of our libraries) for the sake of comparison." << endl;
|
2002-07-17 14:50:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
UnitTesterShell::ProcessArgument(std::string arg, int argc, char *argv[]) {
|
|
|
|
if (arg == "-r5") {
|
|
|
|
doR5Tests = true;
|
|
|
|
} else if (arg == "-obos") {
|
|
|
|
doR5Tests = false;
|
|
|
|
} else
|
|
|
|
return BTestShell::ProcessArgument(arg, argc, argv);
|
|
|
|
|
|
|
|
return true;
|
2002-07-11 07:34:41 +04:00
|
|
|
}
|
|
|
|
|
2002-07-17 14:50:55 +04:00
|
|
|
void
|
|
|
|
UnitTesterShell::LoadDynamicSuites() {
|
|
|
|
// Add the appropriate test lib path
|
|
|
|
fLibDirs.insert(defaultLibDir + (doR5Tests ? "_r5" : ""));
|
|
|
|
|
|
|
|
// Load away
|
|
|
|
BTestShell::LoadDynamicSuites();
|
|
|
|
}
|