$treeview $search $mathjax $extrastylesheet
artdaq_demo
v3_04_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #define BOOST_TEST_MODULE ( NthEvent_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(NthEvent_policy_t) 00010 00011 BOOST_AUTO_TEST_CASE(Simple) 00012 { 00013 fhicl::ParameterSet ps; 00014 fhicl::make_ParameterSet("receiver_ranks: [1,2,3,4] nth_event: 5 target_receiver: 3", ps); 00015 00016 auto nth = artdaq::makeRoutingMasterPolicy("NthEvent", ps); 00017 00018 BOOST_REQUIRE_EQUAL(nth->GetReceiverCount(), 4); 00019 00020 // Extra token, and out of sequence 00021 nth->Reset(); 00022 nth->AddReceiverToken(1, 1); 00023 nth->AddReceiverToken(2, 1); 00024 nth->AddReceiverToken(4, 1); 00025 nth->AddReceiverToken(2, 1); 00026 auto secondTable = nth->GetCurrentTable(); 00027 BOOST_REQUIRE_EQUAL(secondTable.size(), 3); 00028 BOOST_REQUIRE_EQUAL(secondTable[0].destination_rank, 1); 00029 BOOST_REQUIRE_EQUAL(secondTable[0].sequence_id, 1); 00030 BOOST_REQUIRE_EQUAL(secondTable[1].destination_rank, 2); 00031 BOOST_REQUIRE_EQUAL(secondTable[1].sequence_id, 2); 00032 BOOST_REQUIRE_EQUAL(secondTable[2].destination_rank, 4); 00033 BOOST_REQUIRE_EQUAL(secondTable[2].sequence_id, 3); 00034 00035 // Adding empty number of tokens 00036 nth->AddReceiverToken(1, 0); 00037 auto thirdTable = nth->GetCurrentTable(); 00038 BOOST_REQUIRE_EQUAL(thirdTable.size(), 0); 00039 00040 // Catching up to the extra token 00041 nth->AddReceiverToken(1, 2); 00042 nth->AddReceiverToken(3, 2); 00043 nth->AddReceiverToken(4, 2); 00044 auto fourthTable = nth->GetCurrentTable(); 00045 BOOST_REQUIRE_EQUAL(fourthTable.size(), 4); 00046 BOOST_REQUIRE_EQUAL(fourthTable[0].destination_rank, 1); 00047 BOOST_REQUIRE_EQUAL(fourthTable[0].sequence_id, 4); 00048 BOOST_REQUIRE_EQUAL(fourthTable[1].destination_rank, 3); 00049 BOOST_REQUIRE_EQUAL(fourthTable[1].sequence_id, 5); 00050 BOOST_REQUIRE_EQUAL(fourthTable[2].destination_rank, 2); 00051 BOOST_REQUIRE_EQUAL(fourthTable[2].sequence_id, 6); 00052 BOOST_REQUIRE_EQUAL(fourthTable[3].destination_rank, 4); 00053 BOOST_REQUIRE_EQUAL(fourthTable[3].sequence_id, 7); 00054 00055 // Catching up to the missing token 00056 nth->AddReceiverToken(2, 1); 00057 auto fifthTable = nth->GetCurrentTable(); 00058 BOOST_REQUIRE_EQUAL(fifthTable.size(), 4); 00059 BOOST_REQUIRE_EQUAL(fifthTable[0].destination_rank, 1); 00060 BOOST_REQUIRE_EQUAL(fifthTable[0].sequence_id, 8); 00061 BOOST_REQUIRE_EQUAL(fifthTable[1].destination_rank, 2); 00062 BOOST_REQUIRE_EQUAL(fifthTable[1].sequence_id, 9); 00063 BOOST_REQUIRE_EQUAL(fifthTable[2].destination_rank, 3); 00064 BOOST_REQUIRE_EQUAL(fifthTable[2].sequence_id, 10); 00065 BOOST_REQUIRE_EQUAL(fifthTable[3].destination_rank, 4); 00066 BOOST_REQUIRE_EQUAL(fifthTable[3].sequence_id, 11); 00067 00068 // Lots of "normal" tokens 00069 nth->AddReceiverToken(1, 10); 00070 nth->AddReceiverToken(2, 10); 00071 nth->AddReceiverToken(4, 10); 00072 auto sixthTable = nth->GetCurrentTable(); 00073 BOOST_REQUIRE_EQUAL(sixthTable.size(), 3); 00074 BOOST_REQUIRE_EQUAL(sixthTable[0].destination_rank, 1); 00075 BOOST_REQUIRE_EQUAL(sixthTable[0].sequence_id, 12); 00076 BOOST_REQUIRE_EQUAL(sixthTable[1].destination_rank, 2); 00077 BOOST_REQUIRE_EQUAL(sixthTable[1].sequence_id, 13); 00078 BOOST_REQUIRE_EQUAL(sixthTable[2].destination_rank, 4); 00079 BOOST_REQUIRE_EQUAL(sixthTable[2].sequence_id, 14); 00080 00081 // Still no "nth" token 00082 auto blankTable = nth->GetCurrentTable(); 00083 BOOST_REQUIRE_EQUAL(blankTable.size(), 0); 00084 00085 // Some "nth" tokens 00086 nth->AddReceiverToken(3, 3); 00087 auto seventhTable = nth->GetCurrentTable(); 00088 BOOST_REQUIRE_EQUAL(seventhTable.size(), 15); 00089 BOOST_REQUIRE_EQUAL(seventhTable[0].destination_rank, 3); 00090 BOOST_REQUIRE_EQUAL(seventhTable[0].sequence_id, 15); 00091 BOOST_REQUIRE_EQUAL(seventhTable[1].destination_rank, 1); 00092 BOOST_REQUIRE_EQUAL(seventhTable[1].sequence_id, 16); 00093 BOOST_REQUIRE_EQUAL(seventhTable[2].destination_rank, 2); 00094 BOOST_REQUIRE_EQUAL(seventhTable[2].sequence_id, 17); 00095 BOOST_REQUIRE_EQUAL(seventhTable[3].destination_rank, 4); 00096 BOOST_REQUIRE_EQUAL(seventhTable[3].sequence_id, 18); 00097 BOOST_REQUIRE_EQUAL(seventhTable[4].destination_rank, 1); 00098 BOOST_REQUIRE_EQUAL(seventhTable[4].sequence_id, 19); 00099 BOOST_REQUIRE_EQUAL(seventhTable[5].destination_rank, 3); 00100 BOOST_REQUIRE_EQUAL(seventhTable[5].sequence_id, 20); 00101 BOOST_REQUIRE_EQUAL(seventhTable[6].destination_rank, 2); 00102 BOOST_REQUIRE_EQUAL(seventhTable[6].sequence_id, 21); 00103 BOOST_REQUIRE_EQUAL(seventhTable[7].destination_rank, 4); 00104 BOOST_REQUIRE_EQUAL(seventhTable[7].sequence_id, 22); 00105 BOOST_REQUIRE_EQUAL(seventhTable[8].destination_rank, 1); 00106 BOOST_REQUIRE_EQUAL(seventhTable[8].sequence_id, 23); 00107 BOOST_REQUIRE_EQUAL(seventhTable[9].destination_rank, 2); 00108 BOOST_REQUIRE_EQUAL(seventhTable[9].sequence_id, 24); 00109 BOOST_REQUIRE_EQUAL(seventhTable[10].destination_rank, 3); 00110 BOOST_REQUIRE_EQUAL(seventhTable[10].sequence_id, 25); 00111 BOOST_REQUIRE_EQUAL(seventhTable[11].destination_rank, 4); 00112 BOOST_REQUIRE_EQUAL(seventhTable[11].sequence_id, 26); 00113 BOOST_REQUIRE_EQUAL(seventhTable[12].destination_rank, 1); 00114 BOOST_REQUIRE_EQUAL(seventhTable[12].sequence_id, 27); 00115 BOOST_REQUIRE_EQUAL(seventhTable[13].destination_rank, 2); 00116 BOOST_REQUIRE_EQUAL(seventhTable[13].sequence_id, 28); 00117 BOOST_REQUIRE_EQUAL(seventhTable[14].destination_rank, 4); 00118 BOOST_REQUIRE_EQUAL(seventhTable[14].sequence_id, 29); 00119 00120 00121 } 00122 00123 BOOST_AUTO_TEST_SUITE_END()