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 #define BOOST_TEST_MAIN
00033 #define BOOST_TEST_DYN_LINK
00034 #include <boost/test/unit_test.hpp>
00035 
00036 using boost::unit_test::test_suite;
00037 
00038 using namespace RTT;
00039 using namespace std;
00040 
00041 
00042 
00043 
00044 boost::unit_test::test_suite* init_unit_test_suite(int argc, char** const argv)
00045 {
00046     if ( argc > 1 && strncmp(argv[1],"--help",6) == 0 ) {
00047         cout << "This unit test executable takes the following options:" <<endl<<endl;
00048         cout << "The starred option is the default, available options depend on Boost UTF library version." <<endl<<endl;
00049         cout << "  --build_info[=<yes|no*>]          "<<endl;
00050         cout << "  --catch_system_errors[=<yes*|no>  "<<endl;
00051         cout << "  --detect_memory_leaks[=<yes*|no>  "<<endl;
00052         cout << "  --log_format[=<HRF*|XML>          "<<endl;
00053         cout << "  --log_level[=<all|success|test_suite|message|warning|error*|cpp_exception|system_error|fatal_error|nothing>"<<endl;
00054         cout << "  --result_code[=<yes*|no>          "<<endl;
00055         cout << "  --output_format[=<HRF*|XML>       "<<endl;
00056         cout << "  --random[=<0*|1|>1>               "<<endl;
00057         cout << "  --report_format[=<HRF*|XML>       "<<endl;
00058         cout << "  --report level[=<no|confirm*|short|detailed>"<<endl;
00059         cout << "  --show_progress[=<yes|no*>        "<<endl<<endl;
00060         cout << "  --use_alt_stack[=<yes*|no>        "<<endl<<endl;
00061 
00062         cout << "Select tests by using the form:"<<endl;
00063         cout << "  " << argv[0] << " --run_test=suite/testX"<<endl;
00064         cout << "Wildcards are accepted:"<<endl;
00065         cout << "  " << argv[0] << " --run_test=*/testX"<<endl;
00066         exit(0);
00067     }
00068 
00069     // sets environment if not set by user.
00070     // On Unix, the build dir is on the top level, on windows,
00071     // the build dir is for each subdir, so we need two paths
00072     // and find out at run-time which one works.
00073     setenv("RTT_COMPONENT_PATH","../rtt:../../rtt", 0);
00074 #ifdef OS_RT_MALLOC
00075         void*   rtMem=0;
00076         size_t  freeMem=0;
00077 
00079         rtMem           = malloc(BUILD_TEST_RT_MEM_POOL_SIZE);  // don't calloc() as is first thing TLSF does.
00080         assert(0 != rtMem);
00081         freeMem         = init_memory_pool(BUILD_TEST_RT_MEM_POOL_SIZE, rtMem);
00082         assert((size_t)-1 != freeMem); // increase MEMORY_SIZE above most likely, as TLSF has a several kilobyte overhead
00083     (void)freeMem;          // avoid compiler warning
00084 #endif
00085         __os_init(argc, argv);
00086 
00087     // disable logging of errors or warnings if no ORO_LOGLEVEL was set.
00088     if ( log().getLogLevel() == Logger::Warning ) {
00089         log(Info) << "Lowering LogLevel to Critical." << endlog();
00090         log().setLogLevel(Logger::Critical);
00091     } else {
00092         log(Info) << "LogLevel unaltered by test-runner." << endlog();
00093     }
00094 
00095     return 0;
00096 }
00097 
00098 using namespace boost::unit_test;
00099 struct InitOrocos {
00100 public:
00101         InitOrocos(){
00102             init_unit_test_suite(framework::master_test_suite().argc,framework::master_test_suite().argv);
00103         }
00104         ~InitOrocos(){
00105             // If we call __os_exit() in Xenomai, we get an ABORT
00106             // because the main task is cleaned up too early.
00107             // The work around for now is to stop all threads but
00108             // the main thread. To be fixed if boost::test allows it.
00109 #ifndef OROCOS_TARGET_XENOMAI
00110         __os_exit();
00111 #else
00112         os::StartStopManager::Instance()->stop();
00113         os::StartStopManager::Release();
00114 #endif
00115 }
00116 
00117 };
00118 
00119 BOOST_GLOBAL_FIXTURE( InitOrocos )


rtt
Author(s): RTT Developers
autogenerated on Fri Sep 9 2016 04:02:15