test-runner.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002   tag: Peter Soetens  Mon Jan 10 15:59:50 CET 2005  test-runner.cpp
00003 
00004                         test-runner.cpp -  description
00005                            -------------------
00006     begin                : Mon January 10 2005
00007     copyright            : (C) 2005 Peter Soetens
00008     email                : peter.soetens@mech.kuleuven.ac.be
00009 
00010  ***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018 
00019 // need access to all TLSF functions embedded in RTT
00020 // this call must occur before ALL RTT include's!!
00021 #define ORO_MEMORY_POOL
00022 #include <rtt/os/tlsf/tlsf.h>
00023 
00024 #include <os/main.h>
00025 #include <Logger.hpp>
00026 #include <iostream>
00027 #include <cstdlib>
00028 
00029 #include <os/StartStopManager.hpp>
00030 
00031 #include "test-runner.hpp"
00032 #include <boost/test/unit_test.hpp>
00033 #include <boost/test/included/unit_test.hpp>
00034 
00035 using boost::unit_test::test_suite;
00036 
00037 using namespace RTT;
00038 using namespace std;
00039 
00040 struct InitOrocos {
00041 public:
00042         InitOrocos(){  }
00043         ~InitOrocos(){
00044             // If we call __os_exit() in Xenomai, we get an ABORT
00045             // because the main task is cleaned up too early.
00046             // The work around for now is to stop all threads but
00047             // the main thread. To be fixed if boost::test allows it.
00048 #ifndef OROCOS_TARGET_XENOMAI
00049         __os_exit();
00050 #else
00051         os::StartStopManager::Instance()->stop();
00052         os::StartStopManager::Release();
00053 #endif
00054 }
00055 
00056 };
00057 
00058 BOOST_GLOBAL_FIXTURE( InitOrocos )
00059 
00060 boost::unit_test::test_suite* init_unit_test_suite(int argc, char** const argv)
00061 {
00062     if ( argc > 1 && strncmp(argv[1],"--help",6) == 0 ) {
00063         cout << "This unit test executable takes the following options:" <<endl<<endl;
00064         cout << "The starred option is the default, available options depend on Boost UTF library version." <<endl<<endl;
00065         cout << "  --build_info[=<yes|no*>]          "<<endl;
00066         cout << "  --catch_system_errors[=<yes*|no>  "<<endl;
00067         cout << "  --detect_memory_leaks[=<yes*|no>  "<<endl;
00068         cout << "  --log_format[=<HRF*|XML>          "<<endl;
00069         cout << "  --log_level[=<all|success|test_suite|message|warning|error*|cpp_exception|system_error|fatal_error|nothing>"<<endl;
00070         cout << "  --result_code[=<yes*|no>          "<<endl;
00071         cout << "  --output_format[=<HRF*|XML>       "<<endl;
00072         cout << "  --random[=<0*|1|>1>               "<<endl;
00073         cout << "  --report_format[=<HRF*|XML>       "<<endl;
00074         cout << "  --report level[=<no|confirm*|short|detailed>"<<endl;
00075         cout << "  --show_progress[=<yes|no*>        "<<endl<<endl;
00076         cout << "  --use_alt_stack[=<yes*|no>        "<<endl<<endl;
00077 
00078         cout << "Select tests by using the form:"<<endl;
00079         cout << "  " << argv[0] << " --run_test=suite/testX"<<endl;
00080         cout << "Wildcards are accepted:"<<endl;
00081         cout << "  " << argv[0] << " --run_test=*/testX"<<endl;
00082         exit(0);
00083     }
00084 
00085     // sets environment if not set by user.
00086     // On Unix, the build dir is on the top level, on windows,
00087     // the build dir is for each subdir, so we need two paths
00088     // and find out at run-time which one works.
00089     setenv("RTT_COMPONENT_PATH","../rtt:../../rtt", 0);
00090 #ifdef OS_RT_MALLOC
00091         void*   rtMem=0;
00092         size_t  freeMem=0;
00093 
00095         rtMem           = malloc(BUILD_TEST_RT_MEM_POOL_SIZE);  // don't calloc() as is first thing TLSF does.
00096         assert(0 != rtMem);
00097         freeMem         = init_memory_pool(BUILD_TEST_RT_MEM_POOL_SIZE, rtMem);
00098         assert((size_t)-1 != freeMem); // increase MEMORY_SIZE above most likely, as TLSF has a several kilobyte overhead
00099 #endif
00100         __os_init(argc, argv);
00101 
00102     // disable logging of errors or warnings if no ORO_LOGLEVEL was set.
00103     if ( log().getLogLevel() == Logger::Warning ) {
00104         log(Info) << "Lowering LogLevel to Critical." << endlog();
00105         log().setLogLevel(Logger::Critical);
00106     } else {
00107         log(Info) << "LogLevel unaltered by test-runner." << endlog();
00108     }
00109 
00110     return 0;
00111 }
00112 


rtt
Author(s): RTT Developers
autogenerated on Mon Oct 6 2014 03:13:54