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