1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cppstdlib/stl/test/unit/cppunit/test_main.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,114 @@
1.4 +/*
1.5 + * Copyright (c) 2003, 2004
1.6 + * Zdenek Nemec
1.7 + *
1.8 + * This material is provided "as is", with absolutely no warranty expressed
1.9 + * or implied. Any use is at your own risk.
1.10 + *
1.11 + * Permission to use or copy this software for any purpose is hereby granted
1.12 + * without fee, provided the above notices are retained on all copies.
1.13 + * Permission to modify the code and to distribute modified code is granted,
1.14 + * provided the above notices are retained, and a notice that the code was
1.15 + * modified is included with the above copyright notice.
1.16 + *
1.17 + */
1.18 +
1.19 +#include "cppunit_proxy.h"
1.20 +#include "file_reporter.h"
1.21 +#include "cppunit_timer.h"
1.22 +
1.23 +namespace CPPUNIT_NS
1.24 +{
1.25 + int CPPUNIT_NS::TestCase::m_numErrors = 0;
1.26 + int CPPUNIT_NS::TestCase::m_numTests = 0;
1.27 +
1.28 + CPPUNIT_NS::TestCase *CPPUNIT_NS::TestCase::m_root = 0;
1.29 + CPPUNIT_NS::Reporter *CPPUNIT_NS::TestCase::m_reporter = 0;
1.30 +
1.31 + void CPPUNIT_NS::TestCase::registerTestCase(TestCase *in_testCase) {
1.32 + in_testCase->m_next = m_root;
1.33 + m_root = in_testCase;
1.34 + }
1.35 +
1.36 + int CPPUNIT_NS::TestCase::run(Reporter *in_reporter, const char *in_testName, bool invert) {
1.37 + TestCase::m_reporter = in_reporter;
1.38 +
1.39 + m_numErrors = 0;
1.40 + m_numTests = 0;
1.41 +
1.42 + TestCase *tmp = m_root;
1.43 + while (tmp != 0) {
1.44 + in_reporter->setFirstStep(true);
1.45 + tmp->myRun(in_testName, invert);
1.46 + tmp = tmp->m_next;
1.47 + }
1.48 + return m_numErrors;
1.49 + }
1.50 +}
1.51 +
1.52 +int main(int argc, char** argv) {
1.53 +
1.54 + // CppUnit(mini) test launcher
1.55 + // command line option syntax:
1.56 + // test [OPTIONS]
1.57 + // where OPTIONS are
1.58 + // -t=CLASS[::TEST] run the test class CLASS or member test CLASS::TEST
1.59 + // -x=CLASS[::TEST] run all except the test class CLASS or member test CLASS::TEST
1.60 + // -f=FILE save output in file FILE instead of stdout
1.61 + // -m monitor test(s) execution
1.62 + char *fileName = 0;
1.63 + char *testName = "";
1.64 + char *xtestName = "";
1.65 + bool doMonitoring = false;
1.66 +
1.67 + for (int i = 1; i < argc; ++i) {
1.68 + if (argv[i][0] != '-')
1.69 + break;
1.70 + if (!strncmp(argv[i], "-t=", 3)) {
1.71 + testName = argv[i]+3;
1.72 + }
1.73 + else if (!strncmp(argv[i], "-f=", 3)) {
1.74 + fileName = argv[i]+3;
1.75 + }
1.76 + else if (!strncmp(argv[i], "-x=", 3)) {
1.77 + xtestName = argv[i]+3;
1.78 + }
1.79 + else if (Timer::supported() && !strncmp(argv[i], "-m", 2)) {
1.80 + doMonitoring = true;
1.81 + }
1.82 + }
1.83 +
1.84 + CPPUNIT_NS::Reporter* reporter;
1.85 + if (fileName != 0)
1.86 + reporter = new FileReporter(fileName, doMonitoring);
1.87 + else
1.88 + reporter = new FileReporter(stdout, doMonitoring);
1.89 +
1.90 + int num_errors;
1.91 + if (xtestName[0] != 0) {
1.92 + num_errors = CPPUNIT_NS::TestCase::run(reporter, xtestName, true);
1.93 + } else {
1.94 + num_errors = CPPUNIT_NS::TestCase::run(reporter, testName);
1.95 + }
1.96 +
1.97 + reporter->printSummary();
1.98 + delete reporter;
1.99 +
1.100 + return num_errors;
1.101 +}
1.102 +
1.103 +// See doc/README.intel for explanation about this code
1.104 +#if defined (STLPORT) && defined (__ICL) && (__ICL >= 900) && \
1.105 + (_STLP_MSVC_LIB < 1300) && defined (_STLP_USE_DYNAMIC_LIB)
1.106 +# include <exception>
1.107 +
1.108 +# undef std
1.109 +namespace std
1.110 +{
1.111 + void _STLP_CALL unexpected() {
1.112 + unexpected_handler hdl;
1.113 + set_unexpected(hdl = set_unexpected((unexpected_handler)0));
1.114 + hdl();
1.115 + }
1.116 +}
1.117 +#endif