sl@0: /* sl@0: * Copyright (c) 2003, 2004 sl@0: * Zdenek Nemec sl@0: * sl@0: * This material is provided "as is", with absolutely no warranty expressed sl@0: * or implied. Any use is at your own risk. sl@0: * sl@0: * Permission to use or copy this software for any purpose is hereby granted sl@0: * without fee, provided the above notices are retained on all copies. sl@0: * Permission to modify the code and to distribute modified code is granted, sl@0: * provided the above notices are retained, and a notice that the code was sl@0: * modified is included with the above copyright notice. sl@0: * sl@0: */ sl@0: sl@0: #include "cppunit_proxy.h" sl@0: #include "file_reporter.h" sl@0: #include "cppunit_timer.h" sl@0: sl@0: namespace CPPUNIT_NS sl@0: { sl@0: int CPPUNIT_NS::TestCase::m_numErrors = 0; sl@0: int CPPUNIT_NS::TestCase::m_numTests = 0; sl@0: sl@0: CPPUNIT_NS::TestCase *CPPUNIT_NS::TestCase::m_root = 0; sl@0: CPPUNIT_NS::Reporter *CPPUNIT_NS::TestCase::m_reporter = 0; sl@0: sl@0: void CPPUNIT_NS::TestCase::registerTestCase(TestCase *in_testCase) { sl@0: in_testCase->m_next = m_root; sl@0: m_root = in_testCase; sl@0: } sl@0: sl@0: int CPPUNIT_NS::TestCase::run(Reporter *in_reporter, const char *in_testName, bool invert) { sl@0: TestCase::m_reporter = in_reporter; sl@0: sl@0: m_numErrors = 0; sl@0: m_numTests = 0; sl@0: sl@0: TestCase *tmp = m_root; sl@0: while (tmp != 0) { sl@0: in_reporter->setFirstStep(true); sl@0: tmp->myRun(in_testName, invert); sl@0: tmp = tmp->m_next; sl@0: } sl@0: return m_numErrors; sl@0: } sl@0: } sl@0: sl@0: int main(int argc, char** argv) { sl@0: sl@0: // CppUnit(mini) test launcher sl@0: // command line option syntax: sl@0: // test [OPTIONS] sl@0: // where OPTIONS are sl@0: // -t=CLASS[::TEST] run the test class CLASS or member test CLASS::TEST sl@0: // -x=CLASS[::TEST] run all except the test class CLASS or member test CLASS::TEST sl@0: // -f=FILE save output in file FILE instead of stdout sl@0: // -m monitor test(s) execution sl@0: char *fileName = 0; sl@0: char *testName = ""; sl@0: char *xtestName = ""; sl@0: bool doMonitoring = false; sl@0: sl@0: for (int i = 1; i < argc; ++i) { sl@0: if (argv[i][0] != '-') sl@0: break; sl@0: if (!strncmp(argv[i], "-t=", 3)) { sl@0: testName = argv[i]+3; sl@0: } sl@0: else if (!strncmp(argv[i], "-f=", 3)) { sl@0: fileName = argv[i]+3; sl@0: } sl@0: else if (!strncmp(argv[i], "-x=", 3)) { sl@0: xtestName = argv[i]+3; sl@0: } sl@0: else if (Timer::supported() && !strncmp(argv[i], "-m", 2)) { sl@0: doMonitoring = true; sl@0: } sl@0: } sl@0: sl@0: CPPUNIT_NS::Reporter* reporter; sl@0: if (fileName != 0) sl@0: reporter = new FileReporter(fileName, doMonitoring); sl@0: else sl@0: reporter = new FileReporter(stdout, doMonitoring); sl@0: sl@0: int num_errors; sl@0: if (xtestName[0] != 0) { sl@0: num_errors = CPPUNIT_NS::TestCase::run(reporter, xtestName, true); sl@0: } else { sl@0: num_errors = CPPUNIT_NS::TestCase::run(reporter, testName); sl@0: } sl@0: sl@0: reporter->printSummary(); sl@0: delete reporter; sl@0: sl@0: return num_errors; sl@0: } sl@0: sl@0: // See doc/README.intel for explanation about this code sl@0: #if defined (STLPORT) && defined (__ICL) && (__ICL >= 900) && \ sl@0: (_STLP_MSVC_LIB < 1300) && defined (_STLP_USE_DYNAMIC_LIB) sl@0: # include sl@0: sl@0: # undef std sl@0: namespace std sl@0: { sl@0: void _STLP_CALL unexpected() { sl@0: unexpected_handler hdl; sl@0: set_unexpected(hdl = set_unexpected((unexpected_handler)0)); sl@0: hdl(); sl@0: } sl@0: } sl@0: #endif