00001 #define BOOST_TEST_MODULE ( RoundRobin_policy_t ) 00002 #include "boost/test/auto_unit_test.hpp" 00003 00004 #include "artdaq/Application/Routing/makeRoutingMasterPolicy.hh" 00005 #include "fhiclcpp/ParameterSet.h" 00006 #include "fhiclcpp/make_ParameterSet.h" 00007 00008 00009 BOOST_AUTO_TEST_SUITE(RoundRobin_policy_t) 00010 00011 BOOST_AUTO_TEST_CASE(Simple) 00012 { 00013 fhicl::ParameterSet ps; 00014 fhicl::make_ParameterSet("receiver_ranks: [1,2,3,4]", ps); 00015 00016 auto rr = artdaq::makeRoutingMasterPolicy("RoundRobin", ps); 00017 00018 BOOST_REQUIRE_EQUAL(rr->GetReceiverCount(), 4); 00019 00020 rr->Reset(); 00021 rr->AddReceiverToken(1, 1); 00022 rr->AddReceiverToken(3, 1); 00023 rr->AddReceiverToken(2, 1); 00024 rr->AddReceiverToken(4, 1); 00025 rr->AddReceiverToken(2, 1); 00026 auto secondTable = rr->GetCurrentTable(); 00027 BOOST_REQUIRE_EQUAL(secondTable.size(), 4); 00028 BOOST_REQUIRE_EQUAL(secondTable[0].destination_rank, 1); 00029 BOOST_REQUIRE_EQUAL(secondTable[1].destination_rank, 2); 00030 BOOST_REQUIRE_EQUAL(secondTable[2].destination_rank, 3); 00031 BOOST_REQUIRE_EQUAL(secondTable[3].destination_rank, 4); 00032 BOOST_REQUIRE_EQUAL(secondTable[0].sequence_id, 0); 00033 BOOST_REQUIRE_EQUAL(secondTable[1].sequence_id, 1); 00034 BOOST_REQUIRE_EQUAL(secondTable[2].sequence_id, 2); 00035 BOOST_REQUIRE_EQUAL(secondTable[3].sequence_id, 3); 00036 00037 rr->AddReceiverToken(1, 0); 00038 00039 auto thirdTable = rr->GetCurrentTable(); 00040 BOOST_REQUIRE_EQUAL(thirdTable.size(), 0); 00041 00042 rr->AddReceiverToken(1, 2); 00043 rr->AddReceiverToken(2, 1); 00044 rr->AddReceiverToken(3, 1); 00045 rr->AddReceiverToken(4, 2); 00046 auto fourthTable = rr->GetCurrentTable(); 00047 BOOST_REQUIRE_EQUAL(fourthTable.size(), 4); 00048 BOOST_REQUIRE_EQUAL(fourthTable[0].destination_rank, 1); 00049 00050 rr->AddReceiverToken(3, 1); 00051 auto fifthTable = rr->GetCurrentTable(); 00052 BOOST_REQUIRE_EQUAL(fifthTable.size(), 4); 00053 BOOST_REQUIRE_EQUAL(fifthTable[0].destination_rank, 1); 00054 00055 } 00056 00057 BOOST_AUTO_TEST_SUITE_END()