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


rtt
Author(s): RTT Developers
autogenerated on Thu Jan 2 2014 11:35:40