-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtest-runner-corba.cpp
122 lines (102 loc) · 4.68 KB
/
test-runner-corba.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/***************************************************************************
tag: Peter Soetens Mon Jan 10 15:59:50 CET 2005 test-runner.cpp
test-runner.cpp - description
-------------------
begin : Mon January 10 2005
copyright : (C) 2005 Peter Soetens
email : [email protected]
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
// need access to all TLSF functions embedded in RTT
// this call must occur before ALL RTT include's!!
#define ORO_MEMORY_POOL
#include <rtt/os/tlsf/tlsf.h>
#include <os/main.h>
#include <Logger.hpp>
#include <iostream>
#include <os/StartStopManager.hpp>
#include <transports/corba/TaskContextServer.hpp>
#include <transports/corba/CorbaDispatcher.hpp>
#include "test-runner.hpp"
#define BOOST_TEST_MAIN
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
using boost::unit_test::test_suite;
using namespace RTT;
using namespace RTT::corba;
using namespace std;
boost::unit_test::test_suite* init_unit_test_suite(int argc, char** const argv)
{
if ( argc > 1 && strncmp(argv[1],"--help",6) == 0 ) {
cout << "This unit test executable takes the following options:" <<endl<<endl;
cout << "The starred option is the default, available options depend on Boost UTF library version." <<endl<<endl;
cout << " --build_info[=<yes|no*>] "<<endl;
cout << " --catch_system_errors[=<yes*|no> "<<endl;
cout << " --detect_memory_leaks[=<yes*|no> "<<endl;
cout << " --log_format[=<HRF*|XML> "<<endl;
cout << " --log_level[=<all|success|test_suite|message|warning|error*|cpp_exception|system_error|fatal_error|nothing>"<<endl;
cout << " --result_code[=<yes*|no> "<<endl;
cout << " --output_format[=<HRF*|XML> "<<endl;
cout << " --random[=<0*|1|>1> "<<endl;
cout << " --report_format[=<HRF*|XML> "<<endl;
cout << " --report level[=<no|confirm*|short|detailed>"<<endl;
cout << " --show_progress[=<yes|no*> "<<endl<<endl;
cout << " --use_alt_stack[=<yes*|no> "<<endl<<endl;
cout << "Select tests by using the form:"<<endl;
cout << " " << argv[0] << " --run_test=suite/testX"<<endl;
cout << "Wildcards are accepted:"<<endl;
cout << " " << argv[0] << " --run_test=*/testX"<<endl;
exit(0);
}
// sets environment if not set by user.
setenv("RTT_COMPONENT_PATH","../rtt", 0);
#ifdef OS_RT_MALLOC
void* rtMem=0;
size_t freeMem=0;
/// setup real-time memory allocation
rtMem = malloc(BUILD_TEST_RT_MEM_POOL_SIZE); // don't calloc() as is first thing TLSF does.
assert(0 != rtMem);
freeMem = init_memory_pool(BUILD_TEST_RT_MEM_POOL_SIZE, rtMem);
assert((size_t)-1 != freeMem); // increase MEMORY_SIZE above most likely, as TLSF has a several kilobyte overhead
#endif
__os_init(argc, argv);
corba::TaskContextServer::InitOrb(argc,argv);
corba::TaskContextServer::ThreadOrb();
// disable logging of errors or warnings if no ORO_LOGLEVEL was set.
if ( log().getLogLevel() == Logger::Warning ) {
log(Info) << "Lowering LogLevel to Critical." << endlog();
log().setLogLevel(Logger::Critical);
} else {
log(Info) << "LogLevel unaltered by test-runner." << endlog();
}
return 0;
}
using namespace boost::unit_test;
struct InitOrocos {
public:
InitOrocos(){
init_unit_test_suite(framework::master_test_suite().argc,framework::master_test_suite().argv);
}
~InitOrocos(){
corba::CorbaDispatcher::ReleaseAll();
corba::TaskContextServer::ShutdownOrb(true);
corba::TaskContextServer::DestroyOrb();
// If we call __os_exit() in Xenomai, we get an ABORT
// because the main task is cleaned up too early.
// The work around for now is to stop all threads but
// the main thread. To be fixed if boost::test allows it.
#ifndef OROCOS_TARGET_XENOMAI
__os_exit();
#else
os::StartStopManager::Instance()->stop();
os::StartStopManager::Release();
#endif
}
};
BOOST_GLOBAL_FIXTURE( InitOrocos )