Line data Source code
1 : /**
2 : * @file QueueRegistry_test.cxx QueueRegistry class Unit Tests
3 : *
4 : * This is part of the DUNE DAQ Application Framework, copyright 2020.
5 : * Licensing/copyright details are in the COPYING file that you should have
6 : * received with this code.
7 : */
8 :
9 : #include "iomanager/queue/QueueRegistry.hpp"
10 : #include "opmonlib/TestOpMonManager.hpp"
11 :
12 : #include "conffwk/Configuration.hpp"
13 :
14 : #define BOOST_TEST_MODULE QueueRegistry_test // NOLINT
15 :
16 : #include "boost/test/unit_test.hpp"
17 :
18 : #include <map>
19 : #include <memory>
20 : #include <string>
21 : #include <type_traits>
22 : #include <vector>
23 :
24 : BOOST_AUTO_TEST_SUITE(QueueRegistry_test)
25 :
26 : using namespace dunedaq::iomanager;
27 :
28 : struct ConfigurationFixture
29 : {
30 1 : ConfigurationFixture()
31 : {
32 1 : confdb = std::make_shared<dunedaq::conffwk::Configuration>("oksconflibs:test/config/queueregistry_test.data.xml");
33 1 : confdb->get<dunedaq::confmodel::Queue>(queues);
34 1 : };
35 : static std::shared_ptr<dunedaq::conffwk::Configuration> confdb;
36 : static std::vector<const dunedaq::confmodel::Queue*> queues;
37 : };
38 : std::vector<const dunedaq::confmodel::Queue*> ConfigurationFixture::queues;
39 : std::shared_ptr<dunedaq::conffwk::Configuration> ConfigurationFixture::confdb(nullptr);
40 : BOOST_TEST_GLOBAL_FIXTURE(ConfigurationFixture);
41 :
42 2 : BOOST_AUTO_TEST_CASE(Configure)
43 : {
44 1 : dunedaq::opmonlib::TestOpMonManager opmgr;
45 1 : QueueRegistry::get().configure(ConfigurationFixture::queues, opmgr);
46 :
47 3 : BOOST_REQUIRE_EXCEPTION(QueueRegistry::get().configure(ConfigurationFixture::queues, opmgr),
48 : QueueRegistryConfigured,
49 : [&](QueueRegistryConfigured const&) { return true; });
50 1 : }
51 :
52 2 : BOOST_AUTO_TEST_CASE(CreateQueue)
53 : {
54 :
55 1 : auto queue_ptr_deque = QueueRegistry::get().get_queue<int>("test_queue_stddeque");
56 1 : BOOST_REQUIRE(queue_ptr_deque != nullptr);
57 1 : auto queue_ptr_fspsc = QueueRegistry::get().get_queue<int>("test_queue_fspsc");
58 1 : BOOST_REQUIRE(queue_ptr_fspsc != nullptr);
59 1 : auto queue_ptr_fmpmc = QueueRegistry::get().get_queue<int>("test_queue_fmpmc");
60 1 : BOOST_REQUIRE(queue_ptr_fmpmc != nullptr);
61 4 : BOOST_REQUIRE_EXCEPTION(QueueRegistry::get().get_queue<int>("test_queue_unknown"),
62 : QueueTypeUnknown,
63 : [&](QueueTypeUnknown const&) { return true; });
64 1 : }
65 :
66 : BOOST_AUTO_TEST_SUITE_END()
|