Skip to content
Snippets Groups Projects
Commit 0f57c9ee authored by Jens Georg's avatar Jens Georg
Browse files

Simpler way to suppress the

parent e7c2266b
No related branches found
No related tags found
No related merge requests found
......@@ -35,16 +35,6 @@ FIND_PACKAGE(Boost COMPONENTS thread system unit_test_framework)
IF(Boost_UNIT_TEST_FRAMEWORK_FOUND)
set(TESTING_IS_ENABLED "true")
ENABLE_TESTING()
include(CMakePushCheckState)
include(CheckCXXSourceCompiles)
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_LIBRARIES ${Boost_LIBRARIES})
set(CMAKE_REQUIRED_FLAGS "${Boost_CXX_FLAGS} -pedantic-errors")
check_cxx_source_compiles("#define BOOST_TEST_MODULE CheckForSemicolon\n#include <boost/test/included/unit_test.hpp>\nstruct Foo {};\nBOOST_GLOBAL_FIXTURE(Foo);" WE_NEED_SEMICOLON)
cmake_pop_check_state()
if (WE_NEED_SEMICOLON)
add_definitions("-DBOOST_FIXTURE_NEEDS_SEMICOLON")
endif()
ELSE(Boost_UNIT_TEST_FRAMEWORK_FOUND)
message("Boost unit_test_framework, disabling testing")
ENDIF(Boost_UNIT_TEST_FRAMEWORK_FOUND)
......
......@@ -4,11 +4,20 @@
#include "basenameFromAddress.h"
#include <eq_fct.h>
#include <boost/version.hpp>
// these constants don't exist in DOOCS, although they should. We define them
// here for better code readability
static const int ACCESS_RO = 0; // read only
static const int ACCESS_RW = 1; // read/write
// Remove this once we can get rid of xenial
#if BOOST_VERSION < 106501
# define CTK_BOOST_GLOBAL_FIXTURE(f) BOOST_GLOBAL_FIXTURE(f)
#else
# define CTK_BOOST_GLOBAL_FIXTURE(f) BOOST_GLOBAL_FIXTURE(f);
#endif
#define DOOCS_ADAPTER_DEFAULT_FIXTURE \
struct GlobalFixture { \
GlobalFixture() { ChimeraTK::DoocsAdapter::waitUntilInitialised(); } \
......@@ -18,7 +27,7 @@ static const int ACCESS_RW = 1; // read/write
framework::master_test_suite().argc, framework::master_test_suite().argv}; \
}; \
\
BOOST_GLOBAL_FIXTURE(GlobalFixture);
CTK_BOOST_GLOBAL_FIXTURE(GlobalFixture)
#define DOOCS_ADAPTER_DEFAULT_FIXTURE_STATIC_APPLICATION_WITH_CODE(codeBlockStartUp) \
struct GlobalFixture { \
......@@ -39,7 +48,7 @@ static const int ACCESS_RW = 1; // read/write
\
ReferenceTestApplication GlobalFixture::referenceTestApplication{BOOST_STRINGIZE(BOOST_TEST_MODULE)}; \
std::string GlobalFixture::rpcNo; \
BOOST_GLOBAL_FIXTURE(GlobalFixture);
CTK_BOOST_GLOBAL_FIXTURE(GlobalFixture)
#define DOOCS_ADAPTER_DEFAULT_FIXTURE_STATIC_APPLICATION DOOCS_ADAPTER_DEFAULT_FIXTURE_STATIC_APPLICATION_WITH_CODE({})
......
......@@ -5,7 +5,10 @@
//#include <boost/test/test_case_template.hpp>
//#include <boost/mpl/list.hpp>
#include "serverBasedTestTools.h"
#include <boost/filesystem.hpp>
#include <boost/version.hpp>
#include "DoocsAdapter.h"
#include <ChimeraTK/ControlSystemAdapter/Testing/ReferenceTestApplication.h>
......@@ -19,29 +22,7 @@ using namespace boost::unit_test;
using namespace boost::unit_test_framework;
using namespace ChimeraTK;
struct InternalTestServer : public ThreadedDoocsServer {
InternalTestServer(const std::string& serverName) : ThreadedDoocsServer({}, 0, nullptr, false) {
_serverName = serverName;
}
};
struct GlobalFixture {
GlobalFixture() {
boost::filesystem::copy_file(framework::master_test_suite().p_name.value + ".template.conf",
framework::master_test_suite().p_name.value + ".conf", boost::filesystem::copy_option::overwrite_if_exists);
server.start(framework::master_test_suite().argc, framework::master_test_suite().argv);
ChimeraTK::DoocsAdapter::waitUntilInitialised();
}
ReferenceTestApplication referenceTestApplication{framework::master_test_suite().p_name.value};
InternalTestServer server{framework::master_test_suite().p_name.value};
};
#if defined(BOOST_FIXTURE_NEEDS_SEMICOLON)
BOOST_GLOBAL_FIXTURE(GlobalFixture);
#else
BOOST_GLOBAL_FIXTURE(GlobalFixture)
#endif
DOOCS_ADAPTER_DEFAULT_FIXTURE
/// Check that all expected variables are there.
BOOST_AUTO_TEST_CASE(testVariableExistence) {
......
......@@ -13,22 +13,7 @@ using namespace boost::unit_test_framework;
using namespace boost::unit_test;
using namespace ChimeraTK;
struct GlobalFixture {
GlobalFixture() { ChimeraTK::DoocsAdapter::waitUntilInitialised(); }
~GlobalFixture() { referenceTestApplication.releaseManualLoopControl(); }
static ReferenceTestApplication referenceTestApplication;
ThreadedDoocsServer server{BOOST_STRINGIZE(BOOST_TEST_MODULE) ".conf", framework::master_test_suite().argc,
framework::master_test_suite().argv};
};
ReferenceTestApplication GlobalFixture::referenceTestApplication{BOOST_STRINGIZE(BOOST_TEST_MODULE)};
#if defined(BOOST_FIXTURE_NEEDS_SEMICOLON)
BOOST_GLOBAL_FIXTURE(GlobalFixture);
#else
BOOST_GLOBAL_FIXTURE(GlobalFixture)
#endif
DOOCS_ADAPTER_DEFAULT_FIXTURE_STATIC_APPLICATION
// the array must have testStartValue+i at index i.
template<class T>
......@@ -53,9 +38,6 @@ static bool testArrayContent(std::string const& propertyName, T testStartValue,
/// Check that all expected variables are there.
BOOST_AUTO_TEST_CASE(testReadWrite) {
// halt the test application tread
GlobalFixture::referenceTestApplication.initialiseManualLoopControl();
// prepare the x-axis for the float array (we are using the float and double
// scalar)
DoocsServerTestHelper::doocsSet("//FLOAT/START", 12.3);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment