Line data Source code
1 : #include "artdaq-core/Data/Fragment.hh"
2 : #include "artdaq-core/Data/RawEvent.hh"
3 :
4 : #define BOOST_TEST_MODULE(RawEvent_t)
5 : #include <cetlib/quiet_unit_test.hpp>
6 :
7 : BOOST_AUTO_TEST_SUITE(RawEvent_test)
8 :
9 2 : BOOST_AUTO_TEST_CASE(RawEventHeader)
10 : {
11 1 : artdaq::detail::RawEventHeader reh;
12 :
13 1 : BOOST_REQUIRE_EQUAL(reh.run_id, 0);
14 1 : BOOST_REQUIRE_EQUAL(reh.subrun_id, 0);
15 1 : BOOST_REQUIRE_EQUAL(reh.event_id, 0);
16 1 : BOOST_REQUIRE_EQUAL(reh.sequence_id, 0);
17 1 : BOOST_REQUIRE_EQUAL(reh.timestamp, 0);
18 1 : BOOST_REQUIRE_EQUAL(reh.is_complete, false);
19 :
20 3 : TLOG(TLVL_INFO) << "Default RawEventHeader: " << reh;
21 1 : }
22 :
23 2 : BOOST_AUTO_TEST_CASE(RawEvent_Methods)
24 : {
25 1 : artdaq::RawEvent r1(1, 2, 3, 4, 5);
26 :
27 1 : BOOST_REQUIRE_EQUAL(r1.wordCount(), 0);
28 1 : BOOST_REQUIRE_EQUAL(r1.runID(), 1);
29 1 : BOOST_REQUIRE_EQUAL(r1.subrunID(), 2);
30 1 : BOOST_REQUIRE_EQUAL(r1.eventID(), 3);
31 1 : BOOST_REQUIRE_EQUAL(r1.sequenceID(), 4);
32 1 : BOOST_REQUIRE_EQUAL(r1.timestamp(), 5);
33 1 : BOOST_REQUIRE_EQUAL(r1.isComplete(), false);
34 :
35 1 : artdaq::FragmentPtr frag = std::make_unique<artdaq::Fragment>(101, 202, artdaq::Fragment::DataFragmentType, 303);
36 1 : r1.insertFragment(std::move(frag));
37 :
38 1 : r1.markComplete();
39 1 : BOOST_REQUIRE_EQUAL(r1.isComplete(), true);
40 :
41 3 : TLOG(TLVL_INFO) << "RawEvent: " << r1;
42 1 : }
43 :
44 2 : BOOST_AUTO_TEST_CASE(InsertFragment)
45 : {
46 : // SCF - The RawEvent::insertFragment() method used to check and verify that
47 : // the sequence ID of the fragment equaled the sequence ID in the RawEvent
48 : // header. This doesn't work for the DS50 aggregator as it packs multiple
49 : // fragments with different sequence IDs into a single RawEvent. This test
50 : // verifies that the we're able to do this.
51 1 : artdaq::RawEvent r1(1, 2, 3, 4, 5);
52 1 : std::unique_ptr<artdaq::Fragment> f1(new artdaq::Fragment(1, 1));
53 1 : std::unique_ptr<artdaq::Fragment> f2(new artdaq::Fragment(2, 1));
54 1 : std::unique_ptr<artdaq::Fragment> f3(new artdaq::Fragment(3, 1));
55 :
56 1 : r1.insertFragment(std::move(f1));
57 1 : r1.insertFragment(std::move(f2));
58 1 : r1.insertFragment(std::move(f3));
59 1 : BOOST_REQUIRE_EQUAL(r1.numFragments(), 3);
60 :
61 1 : f1.reset(nullptr);
62 2 : BOOST_REQUIRE_EXCEPTION(r1.insertFragment(std::move(f1)), cet::exception,
63 : [&](cet::exception e) { return e.category() == "LogicError"; });
64 1 : }
65 :
66 : BOOST_AUTO_TEST_SUITE_END()
|