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


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