1 #include "artdaq/DAQrate/DataReceiverManager.hh"
3 #define BOOST_TEST_MODULE DataReceiverManager_t
4 #include "cetlib/quiet_unit_test.hpp"
5 #include "cetlib_except/exception.h"
6 #include "artdaq/TransferPlugins/ShmemTransfer.hh"
9 BOOST_AUTO_TEST_SUITE(DataReceiverManager_test)
11 BOOST_AUTO_TEST_CASE(Construct) {
12 fhicl::ParameterSet pset;
13 pset.put(
"use_art",
false);
14 pset.put(
"buffer_count", 2);
15 pset.put(
"max_event_size_bytes", 1000);
16 pset.put(
"expected_fragments_per_event", 2);
18 fhicl::ParameterSet source_fhicl;
19 source_fhicl.put(
"transferPluginType",
"Shmem");
20 source_fhicl.put(
"destination_rank", 1);
21 source_fhicl.put(
"source_rank", 0);
23 fhicl::ParameterSet sources_fhicl;
24 sources_fhicl.put(
"shmem", source_fhicl);
25 pset.put(
"sources", sources_fhicl);
26 auto shm = std::make_shared<artdaq::SharedMemoryEventManager>(pset, pset);
30 BOOST_AUTO_TEST_CASE(ReceiveData)
32 artdaq::configureMessageFacility(
"DataReceiverManager_t");
33 fhicl::ParameterSet pset;
34 pset.put(
"use_art",
false);
35 pset.put(
"buffer_count", 2);
36 pset.put(
"max_event_size_bytes", 1000);
37 pset.put(
"expected_fragments_per_event", 2);
39 fhicl::ParameterSet source_fhicl;
40 source_fhicl.put(
"transferPluginType",
"Shmem");
41 source_fhicl.put(
"destination_rank", 1);
42 source_fhicl.put(
"source_rank", 0);
43 source_fhicl.put(
"shm_key", 0xFEEE0000 + getpid());
45 fhicl::ParameterSet sources_fhicl;
46 sources_fhicl.put(
"shmem", source_fhicl);
47 pset.put(
"sources", sources_fhicl);
48 auto shm = std::make_shared<artdaq::SharedMemoryEventManager>(pset, pset);
52 BOOST_REQUIRE_EQUAL(t.getSharedMemoryEventManager().get(), shm.get());
53 BOOST_REQUIRE_EQUAL(t.enabled_sources().size(), 1);
54 BOOST_REQUIRE_EQUAL(t.running_sources().size(), 0);
56 BOOST_REQUIRE_EQUAL(t.enabled_sources().size(), 1);
57 BOOST_REQUIRE_EQUAL(t.running_sources().size(), 1);
59 artdaq::Fragment testFrag(10);
60 testFrag.setSequenceID(1);
61 testFrag.setFragmentID(0);
62 testFrag.setTimestamp(0x100);
63 testFrag.setSystemType(artdaq::Fragment::DataFragmentType);
65 transfer.transfer_fragment_reliable_mode(std::move(testFrag));
68 BOOST_REQUIRE_EQUAL(t.count(), 1);
69 BOOST_REQUIRE_EQUAL(t.slotCount(0), 1);
70 BOOST_REQUIRE_EQUAL(t.byteCount(), (10 + artdaq::detail::RawFragmentHeader::num_words()) *
sizeof(artdaq::RawDataType));
72 artdaq::FragmentPtr eodFrag = artdaq::Fragment::eodFrag(1);
74 transfer.transfer_fragment_reliable_mode(std::move(*(eodFrag.get())));
77 BOOST_REQUIRE_EQUAL(t.count(), 1);
78 BOOST_REQUIRE_EQUAL(t.slotCount(0), 1);
79 BOOST_REQUIRE_EQUAL(t.enabled_sources().size(), 1);
80 BOOST_REQUIRE_EQUAL(t.running_sources().size(), 0);
84 BOOST_AUTO_TEST_SUITE_END()
This TransferInterface is a Sender.
Receives Fragment objects from one or more DataSenderManager instances using TransferInterface plugin...
A TransferInterface implementation plugin that transfers data using Shared Memory.