test-runner.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Mon Jan 10 15:59:50 CET 2005 test-runner.cpp
3 
4  test-runner.cpp - description
5  -------------------
6  begin : Mon January 10 2005
7  copyright : (C) 2005 Peter Soetens
8  email : peter.soetens@mech.kuleuven.ac.be
9 
10  ***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 // need access to all TLSF functions embedded in RTT
20 // this call must occur before ALL RTT include's!!
21 #define ORO_MEMORY_POOL
22 #include <rtt/os/tlsf/tlsf.h>
23 
24 #include <os/main.h>
25 #include <Logger.hpp>
26 #include <iostream>
27 #include <cstdlib>
28 
29 #include <os/StartStopManager.hpp>
30 
31 #include "test-runner.hpp"
32 #define BOOST_TEST_MAIN
33 #define BOOST_TEST_DYN_LINK
34 #include <boost/test/unit_test.hpp>
35 #include <boost/version.hpp>
36 
37 using boost::unit_test::test_suite;
38 
39 using namespace RTT;
40 using namespace std;
41 
42 
43 
44 
45 boost::unit_test::test_suite* init_unit_test_suite(int argc, char** const argv)
46 {
47  if ( argc > 1 && strncmp(argv[1],"--help",6) == 0 ) {
48  cout << "This unit test executable takes the following options:" <<endl<<endl;
49  cout << "The starred option is the default, available options depend on Boost UTF library version." <<endl<<endl;
50  cout << " --build_info[=<yes|no*>] "<<endl;
51  cout << " --catch_system_errors[=<yes*|no> "<<endl;
52  cout << " --detect_memory_leaks[=<yes*|no> "<<endl;
53  cout << " --log_format[=<HRF*|XML> "<<endl;
54  cout << " --log_level[=<all|success|test_suite|message|warning|error*|cpp_exception|system_error|fatal_error|nothing>"<<endl;
55  cout << " --result_code[=<yes*|no> "<<endl;
56  cout << " --output_format[=<HRF*|XML> "<<endl;
57  cout << " --random[=<0*|1|>1> "<<endl;
58  cout << " --report_format[=<HRF*|XML> "<<endl;
59  cout << " --report level[=<no|confirm*|short|detailed>"<<endl;
60  cout << " --show_progress[=<yes|no*> "<<endl<<endl;
61  cout << " --use_alt_stack[=<yes*|no> "<<endl<<endl;
62 
63  cout << "Select tests by using the form:"<<endl;
64  cout << " " << argv[0] << " --run_test=suite/testX"<<endl;
65  cout << "Wildcards are accepted:"<<endl;
66  cout << " " << argv[0] << " --run_test=*/testX"<<endl;
67  exit(0);
68  }
69 
70  // sets environment if not set by user.
71  // On Unix, the build dir is on the top level, on windows,
72  // the build dir is for each subdir, so we need two paths
73  // and find out at run-time which one works.
74  setenv("RTT_COMPONENT_PATH","../rtt:../../rtt", 0);
75 #ifdef OS_RT_MALLOC
76  void* rtMem=0;
77  size_t freeMem=0;
78 
80  rtMem = malloc(BUILD_TEST_RT_MEM_POOL_SIZE); // don't calloc() as is first thing TLSF does.
81  assert(0 != rtMem);
82  freeMem = init_memory_pool(BUILD_TEST_RT_MEM_POOL_SIZE, rtMem);
83  assert((size_t)-1 != freeMem); // increase MEMORY_SIZE above most likely, as TLSF has a several kilobyte overhead
84  (void)freeMem; // avoid compiler warning
85 #endif
86  __os_init(argc, argv);
87 
88  // disable logging of errors or warnings if no ORO_LOGLEVEL was set.
89  if ( log().getLogLevel() == Logger::Warning ) {
90  log(Info) << "Lowering LogLevel to Critical." << endlog();
92  } else {
93  log(Info) << "LogLevel unaltered by test-runner." << endlog();
94  }
95 
96  return 0;
97 }
98 
99 using namespace boost::unit_test;
100 struct InitOrocos {
101 public:
103  init_unit_test_suite(framework::master_test_suite().argc,framework::master_test_suite().argv);
104  }
106  // If we call __os_exit() in Xenomai, we get an ABORT
107  // because the main task is cleaned up too early.
108  // The work around for now is to stop all threads but
109  // the main thread. To be fixed if boost::test allows it.
110 #ifndef OROCOS_TARGET_XENOMAI
111  __os_exit();
112 #else
115 #endif
116 }
117 
118 };
119 
120 #if BOOST_VERSION >= 106000
122 #else
124 #endif
int __os_init(int argc, char **argv)
Definition: startstop.cpp:79
Definition: mystd.hpp:163
size_t init_memory_pool(size_t mem_pool_size, void *mem_pool)
Definition: tlsf.c:497
static StartStopManager * Instance()
void __os_exit(void)
Definition: startstop.cpp:166
printstream cout
Definition: rtstreams.cpp:45
#define BOOST_GLOBAL_FIXTURE(F)
basic_ostreams & endl(basic_ostreams &s)
Definition: rtstreams.cpp:110
boost::unit_test::test_suite * init_unit_test_suite(int argc, char **const argv)
Definition: test-runner.cpp:45
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:53
int setenv(const char *name, const char *value, int overwrite)
Definition: fosi.cpp:64
void stop()
Call all registered stop functions.
static Logger & log()
Definition: Logger.hpp:350
static Logger::LogFunction endlog()
Definition: Logger.hpp:362
void setLogLevel(LogLevel ll)
Definition: Logger.cpp:606


rtt
Author(s): RTT Developers
autogenerated on Tue Jun 25 2019 19:33:37