xref: /haiku/src/tests/UnitTester.cpp (revision d3d8b26997fac34a84981e6d2b649521de2cc45a)
1 #include <iostream>
2 
3 #include "UnitTester.h"
4 #include <SemaphoreSyncObject.h>
5 #include <Directory.h>
6 
7 // ##### Include headers for statically linked tests here #####
8 //#include <ExampleTest.h>
9 
10 
11 int main(int argc, char *argv[]) {
12 	UnitTesterShell shell("OpenBeOS Unit Testing Framework", new SemaphoreSyncObject);
13 	// ##### Add test suites for statically linked tests here #####
14 //	shell.AddTest( "Example", ExampleTest::Suite() );
15 
16 	BTestShell::SetGlobalShell(&shell);
17 
18 	// Load our dynamically linked tests
19 
20 	int result = shell.Run(argc, argv);
21 
22 	// Unset global shell, just to be sure
23 	BTestShell::SetGlobalShell(NULL);
24 
25 	return result;
26 }
27 
28 //const string UnitTesterShell::defaultLibDir = "./lib";
29 
30 UnitTesterShell::UnitTesterShell(const string &description, SyncObject *syncObject)
31 	: BTestShell(description, syncObject)
32 {
33 }
34 
35 void
36 UnitTesterShell::PrintDescription(int argc, char *argv[]) {
37 	string AppName = argv[0];
38 	cout << endl;
39 	cout << "This program is the central testing framework for the purpose" << endl;
40 	cout << "of testing and verifying the various kits, classes, functions," << endl;
41 	cout << "and the like that comprise OpenBeOS." << endl;
42 }
43 
44 void
45 UnitTesterShell::PrintValidArguments() {
46 	BTestShell::PrintValidArguments();
47 	cout << indent << "-obos        Runs tests linked against our OpenBeOS libraries (*default*)" << endl;
48 	cout << indent << "-r5          Runs tests linked against Be Inc.'s R5 libraries (instead" << endl;
49 	cout << indent << "             of our libraries) for the sake of comparison." << endl;
50 }
51 
52 void
53 UnitTesterShell::LoadDynamicSuites() {
54 	// Add the appropriate test lib path
55 	string defaultLibDir = string(GlobalTestDir()) + "/lib";
56 	fLibDirs.insert(defaultLibDir);
57 
58 	// Load away
59 	BTestShell::LoadDynamicSuites();
60 }
61