artdaq  v3_09_01
NoOp_policy_t.cc
1 #define BOOST_TEST_MODULE NoOp_policy_t
2 #include <boost/test/unit_test.hpp>
3 
4 #include "artdaq/RoutingPolicies/makeRoutingManagerPolicy.hh"
5 #include "fhiclcpp/ParameterSet.h"
6 #include "fhiclcpp/make_ParameterSet.h"
7 
8 BOOST_AUTO_TEST_SUITE(NoOp_policy_t)
9 
10 BOOST_AUTO_TEST_CASE(Simple)
11 {
12  fhicl::ParameterSet ps;
13  fhicl::make_ParameterSet("receiver_ranks: [1,2,3,4]", ps);
14 
15  auto noop = artdaq::makeRoutingManagerPolicy("NoOp", ps);
16 
17  BOOST_REQUIRE_EQUAL(noop->GetReceiverCount(), 4);
18 
19  noop->Reset();
20  noop->AddReceiverToken(1, 1);
21  noop->AddReceiverToken(3, 1);
22  noop->AddReceiverToken(2, 1);
23  noop->AddReceiverToken(4, 1);
24  noop->AddReceiverToken(2, 1);
25  auto secondTable = noop->GetCurrentTable();
26  BOOST_REQUIRE_EQUAL(secondTable.size(), 5);
27  BOOST_REQUIRE_EQUAL(secondTable[0].destination_rank, 1);
28  BOOST_REQUIRE_EQUAL(secondTable[1].destination_rank, 3);
29  BOOST_REQUIRE_EQUAL(secondTable[2].destination_rank, 2);
30  BOOST_REQUIRE_EQUAL(secondTable[3].destination_rank, 4);
31  BOOST_REQUIRE_EQUAL(secondTable[4].destination_rank, 2);
32  BOOST_REQUIRE_EQUAL(secondTable[0].sequence_id, 1);
33  BOOST_REQUIRE_EQUAL(secondTable[1].sequence_id, 2);
34  BOOST_REQUIRE_EQUAL(secondTable[2].sequence_id, 3);
35  BOOST_REQUIRE_EQUAL(secondTable[3].sequence_id, 4);
36  BOOST_REQUIRE_EQUAL(secondTable[4].sequence_id, 5);
37 
38  noop->AddReceiverToken(1, 0);
39 
40  auto thirdTable = noop->GetCurrentTable();
41  BOOST_REQUIRE_EQUAL(thirdTable.size(), 0);
42 }
43 
44 BOOST_AUTO_TEST_SUITE_END()
std::shared_ptr< RoutingManagerPolicy > makeRoutingManagerPolicy(std::string const &policy_plugin_spec, fhicl::ParameterSet const &ps)
Load a RoutingManagerPolicy plugin.