1 #include <string> 2 #include <iostream> 3 #include <unistd.h> 4 5 #include <Path.h> 6 7 /* Since some of our obos libraries (such as libtranslation.so) have 8 identically named R5 equivalents, it was necessary to have two 9 separate unit testing programs, each with their own lib/ subdir, 10 to make sure that the obos tests are run with obos libs while 11 the r5 tests are run with r5 libs. 12 13 In the interest of keeping things simple (and not invalidating 14 the instructions sitting in the newsletter article I wrote :-), 15 this shell program has been created to allow all unit tests to 16 still be run from a single application. All it does is filter 17 out "-obos" and "-r5" arguments and run the appropriate 18 UnitTesterHelper program (which does all the hard work). 19 */ 20 int main(int argc, char *argv[]) { 21 // Look for "-obos" or "-r5" arguments, then run 22 // the appropriate UnitTesterHelper program, letting 23 // it do all the dirty work. 24 bool doR5Tests = false; 25 bool beVerbose = false; 26 std::string cmd = ""; 27 for (int i = 1; i < argc; i++) { 28 std::string arg(argv[i]); 29 if (arg == "-r5") 30 doR5Tests = true; 31 else if (arg == "-obos") 32 doR5Tests = false; 33 else { 34 if (arg.length() == 3 && arg[0] == '-' && arg[1] == 'v' 35 && '0' <= arg[2] && arg[2] <= '9') 36 { 37 beVerbose = (arg[2] - '0') >= 4; 38 } 39 cmd += " " + arg; 40 } 41 } 42 // get test dir path 43 BPath path(argv[0]); 44 if (path.InitCheck() == B_OK) { 45 if (path.GetParent(&path) != B_OK) 46 cout << "Couldn't get test dir." << endl; 47 } else 48 cout << "Couldn't find the path to the test app." << endl; 49 // construct the command path 50 cmd = (doR5Tests ? "unittester_r5/UnitTesterHelper_r5" : "unittester/UnitTesterHelper") + cmd; 51 cmd = string(path.Path()) + "/" + cmd; 52 if (beVerbose) 53 cout << "Executing: '" << cmd << "'" << endl; 54 system(cmd.c_str()); 55 return 0; 56 } 57 58