ChimeraTK-DeviceAccess 03.25.00
Loading...
Searching...
No Matches
testRunTimeBackendLoading.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
4#define BOOST_TEST_DYN_LINK
5#define BOOST_TEST_MODULE BackendLoadingTest
6#include <boost/test/unit_test.hpp>
7using namespace boost::unit_test_framework;
8
9// #include <cstdio>
10// #include <boost/make_shared.hpp>
11
12#include "BackendFactory.h"
13#include "Exception.h"
14using namespace ChimeraTK;
15
16BOOST_AUTO_TEST_SUITE(BackendLoadingTestSuite)
17
18BOOST_AUTO_TEST_CASE(testBackendLoading) {
20
21 // check that we can load backends always known to the factory,
22 // but we cannot load the one coming from the plugin to exclude that we
23 // accidentally already linkes the so file we want to load
24 BOOST_CHECK_NO_THROW(BackendFactory::getInstance().createBackend("(dummy?map=goodMapFile.map)"));
25 BOOST_CHECK_THROW(
26 BackendFactory::getInstance().createBackend("(working?map=goodMapFile.map"), ChimeraTK::logic_error);
27
28 BackendFactory::getInstance().setDMapFilePath("runtimeLoading/wrongVersionPlugin.dmap");
29 // although a plugin with a wrong version was in the dmap file, the other
30 // backends can still be opended
31 BOOST_CHECK_NO_THROW(BackendFactory::getInstance().createBackend("MY_DUMMY"));
32
33 // Only when we access the one where loading failed we get an error
34 // (not using boost throw to print excaption.what())
35 BOOST_CHECK_THROW(BackendFactory::getInstance().createBackend("WRONG_VERSION"), ChimeraTK::logic_error);
36
37 // Now try loading valid plugins
38 BackendFactory::getInstance().setDMapFilePath("runtimeLoading/runtimeLoading.dmap");
39 // Each call of createBackend is loading the plugins. Check that this is not
40 // causing problems.
41 BOOST_CHECK_NO_THROW(BackendFactory::getInstance().createBackend("WORKING"));
42 BOOST_CHECK_NO_THROW(BackendFactory::getInstance().createBackend("ANOTHER"));
43}
44
45BOOST_AUTO_TEST_SUITE_END()
static BackendFactory & getInstance()
Static function to get an instance of factory.
void setDMapFilePath(std::string dMapFilePath)
This function sets the _DMapFilePath.
Exception thrown when a logic error has occured.
Definition Exception.h:51
BOOST_AUTO_TEST_CASE(testBackendLoading)