Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygentest_main.cpp
Go to the documentation of this file.
00001 /* 00002 * Copyright (c) 2003, 2004 00003 * Zdenek Nemec 00004 * 00005 * This material is provided "as is", with absolutely no warranty expressed 00006 * or implied. Any use is at your own risk. 00007 * 00008 * Permission to use or copy this software for any purpose is hereby granted 00009 * without fee, provided the above notices are retained on all copies. 00010 * Permission to modify the code and to distribute modified code is granted, 00011 * provided the above notices are retained, and a notice that the code was 00012 * modified is included with the above copyright notice. 00013 * 00014 */ 00015 00016 #include "cppunit_proxy.h" 00017 #include "file_reporter.h" 00018 #include "cppunit_timer.h" 00019 00020 #include "stdio.h" 00021 00022 #if 0 00023 namespace CPPUNIT_NS 00024 { 00025 #endif 00026 int TestCase::m_numErrors = 0; 00027 int TestCase::m_numTests = 0; 00028 00029 TestCase *TestCase::m_root = 0; 00030 Reporter *TestCase::m_reporter = 0; 00031 00032 void TestCase::registerTestCase(TestCase *in_testCase) { 00033 in_testCase->m_next = m_root; 00034 m_root = in_testCase; 00035 } 00036 00037 int TestCase::run(Reporter *in_reporter, const char *in_testName, bool invert) { 00038 TestCase::m_reporter = in_reporter; 00039 00040 m_numErrors = 0; 00041 m_numTests = 0; 00042 00043 TestCase *tmp = m_root; 00044 while (tmp != 0) { 00045 tmp->myRun(in_testName, invert); 00046 tmp = tmp->m_next; 00047 } 00048 return m_numErrors; 00049 } 00050 #if 0 00051 } 00052 #endif 00053 00054 static void usage(const char* name) 00055 { 00056 printf("Usage : %s [-t=<class>[::<test>]] [-x=<class>[::<test>]] [-f=<file>]%s\n", 00057 name, Timer::supported() ? " [-m]": ""); 00058 printf("\t[-t=<class>[::<test>]] : test class or class::test to execute;\n"); 00059 printf("\t[-x=<class>[::<test>]] : test class or class::test to exclude from execution;\n"); 00060 printf("\t[-f=<file>] : output file"); 00061 if (Timer::supported()) 00062 printf(";\n\t[-m] : monitor test execution, display time duration for each test\n"); 00063 else 00064 printf("\n"); 00065 } 00066 00067 int main(int argc, char** argv) { 00068 00069 // CppUnit(mini) test launcher 00070 // command line option syntax: 00071 // test [OPTIONS] 00072 // where OPTIONS are 00073 // -t=CLASS[::TEST] run the test class CLASS or member test CLASS::TEST 00074 // -x=CLASS[::TEST] run all except the test class CLASS or member test CLASS::TEST 00075 // -f=FILE save output in file FILE instead of stdout 00076 // -m monitor test(s) execution 00077 const char *fileName = 0; 00078 const char *testName = ""; 00079 const char *xtestName = ""; 00080 bool doMonitoring = false; 00081 00082 for (int i = 1; i < argc; ++i) { 00083 if (argv[i][0] == '-') { 00084 if (!strncmp(argv[i], "-t=", 3)) { 00085 testName = argv[i]+3; 00086 continue; 00087 } 00088 else if (!strncmp(argv[i], "-f=", 3)) { 00089 fileName = argv[i]+3; 00090 continue; 00091 } 00092 else if (!strncmp(argv[i], "-x=", 3)) { 00093 xtestName = argv[i]+3; 00094 continue; 00095 } 00096 else if (Timer::supported() && !strncmp(argv[i], "-m", 2)) { 00097 doMonitoring = true; 00098 continue; 00099 } 00100 } 00101 00102 // invalid option, we display normal usage. 00103 usage(argv[0]); 00104 return 1; 00105 } 00106 00107 CPPUNIT_NS::Reporter* reporter; 00108 if (fileName != 0) 00109 reporter = new FileReporter(fileName, doMonitoring); 00110 else 00111 reporter = new FileReporter(stdout, doMonitoring); 00112 00113 int num_errors; 00114 if (xtestName[0] != 0) { 00115 num_errors = CPPUNIT_NS::TestCase::run(reporter, xtestName, true); 00116 } else { 00117 num_errors = CPPUNIT_NS::TestCase::run(reporter, testName); 00118 } 00119 00120 reporter->printSummary(); 00121 delete reporter; 00122 00123 return num_errors; 00124 } 00125 00126 // See doc/README.intel for explanation about this code 00127 #if defined (STLPORT) && defined (__ICL) && (__ICL >= 900) && \ 00128 (_STLP_MSVC_LIB < 1300) && defined (_STLP_USE_DYNAMIC_LIB) 00129 # include <exception> 00130 00131 # undef std 00132 namespace std 00133 { 00134 void _STLP_CALL unexpected() { 00135 unexpected_handler hdl; 00136 set_unexpected(hdl = set_unexpected((unexpected_handler)0)); 00137 hdl(); 00138 } 00139 } 00140 #endif Generated on Sat May 26 2012 04:34:11 for ReactOS by
1.7.6.1
|