xref: /haiku/src/tests/UnitTester.cpp (revision 52702ce24d98b981e2034192cd86b2f614096611)
1 /*
2  * Copyright 2002-2010, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include <stdio.h>
8 
9 #include <SemaphoreSyncObject.h>
10 #include <Directory.h>
11 
12 #include "UnitTester.h"
13 
14 
UnitTesterShell(const std::string & description,SyncObject * syncObject)15 UnitTesterShell::UnitTesterShell(const std::string &description,
16 	SyncObject *syncObject)
17 	:
18 	BTestShell(description, syncObject)
19 {
20 }
21 
22 
23 void
PrintDescription(int argc,char * argv[])24 UnitTesterShell::PrintDescription(int argc, char *argv[])
25 {
26 	printf("This program is the central testing framework for the purpose\n"
27 		"of testing and verifying the various kits, classes, functions,\n"
28 		"and the like that comprise Haiku.\n");
29 }
30 
31 
32 void
PrintValidArguments()33 UnitTesterShell::PrintValidArguments()
34 {
35 	BTestShell::PrintValidArguments();
36 	printf("  -haiku       Runs tests linked against our Haiku "
37 			"libraries (*default*)\n"
38 		"  -r5          Runs tests linked against Be Inc.'s R5 "
39 			"libraries (instead\n"
40 		"               of our libraries) for the sake of comparison.\n");
41 }
42 
43 
44 void
LoadDynamicSuites()45 UnitTesterShell::LoadDynamicSuites()
46 {
47 	// Add the appropriate test lib path
48 	std::string defaultLibDir = std::string(GlobalTestDir()) + "/lib";
49 	fLibDirs.insert(defaultLibDir);
50 
51 	// Load away
52 	BTestShell::LoadDynamicSuites();
53 }
54 
55 
56 // #pragma mark -
57 
58 
59 int
main(int argc,char * argv[])60 main(int argc, char *argv[])
61 {
62 	UnitTesterShell shell("Haiku Unit Testing Framework",
63 		new SemaphoreSyncObject);
64 
65 	// ##### Add test suites for statically linked tests here #####
66 	//shell.AddTest("Example", ExampleTest::Suite());
67 
68 	BTestShell::SetGlobalShell(&shell);
69 
70 	// Load our dynamically linked tests
71 
72 	int result = shell.Run(argc, argv);
73 
74 	// Unset global shell, just to be sure
75 	BTestShell::SetGlobalShell(NULL);
76 
77 	return result;
78 }
79