|
| 1 | +// Copyright CERN and copyright holders of ALICE O2. This software is |
| 2 | +// distributed under the terms of the GNU General Public License v3 (GPL |
| 3 | +// Version 3), copied verbatim in the file "COPYING". |
| 4 | +// |
| 5 | +// See http://alice-o2.web.cern.ch/license for full licensing information. |
| 6 | +// |
| 7 | +// In applying this license CERN does not waive the privileges and immunities |
| 8 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 9 | +// or submit itself to any jurisdiction. |
| 10 | + |
| 11 | +#define BOOST_TEST_MODULE Test TPC CalDet class |
| 12 | +#define BOOST_TEST_MAIN |
| 13 | +#define BOOST_TEST_DYN_LINK |
| 14 | +#include <boost/test/unit_test.hpp> |
| 15 | + |
| 16 | +#include <vector> |
| 17 | + |
| 18 | +#include "Headers/RAWDataHeader.h" |
| 19 | +#include "TPCBase/RDHUtils.h" |
| 20 | + |
| 21 | +namespace o2 |
| 22 | +{ |
| 23 | +namespace tpc |
| 24 | +{ |
| 25 | +using namespace rdh_utils; |
| 26 | + |
| 27 | +struct FEEDetails { |
| 28 | + FEEDetails(FEEIDType c, FEEIDType e, FEEIDType l) : cru(c), endpoint(e), link(l), feeID((cru << 7) | (endpoint << 6) | link), userLogic(l == UserLogicLinkID) {} |
| 29 | + FEEIDType cru{}; |
| 30 | + FEEIDType endpoint{}; |
| 31 | + FEEIDType link{}; |
| 32 | + FEEIDType feeID{}; |
| 33 | + bool userLogic{}; |
| 34 | +}; |
| 35 | + |
| 36 | +BOOST_AUTO_TEST_CASE(testRDHUtils) |
| 37 | +{ |
| 38 | + // coose some random values |
| 39 | + std::vector<FEEDetails> testDetails; |
| 40 | + testDetails.emplace_back(359, 1, 15); |
| 41 | + testDetails.emplace_back(1, 0, 10); |
| 42 | + testDetails.emplace_back(100, 1, 8); |
| 43 | + testDetails.emplace_back(142, 0, 1); |
| 44 | + testDetails.emplace_back(225, 1, 9); |
| 45 | + |
| 46 | + o2::header::RAWDataHeaderV4 rdh4; |
| 47 | + o2::header::RAWDataHeaderV5 rdh5; |
| 48 | + o2::header::RAWDataHeaderV6 rdh6; |
| 49 | + |
| 50 | + for (const auto& fee : testDetails) { |
| 51 | + const auto feeID = getFEEID(fee.cru, fee.endpoint, fee.link); |
| 52 | + |
| 53 | + // default checks |
| 54 | + auto cru = getCRU(feeID); |
| 55 | + auto link = getLink(feeID); |
| 56 | + auto endpoint = getEndPoint(feeID); |
| 57 | + bool userLogic = isFromUserLogic(feeID); |
| 58 | + |
| 59 | + BOOST_CHECK_EQUAL(feeID, fee.feeID); |
| 60 | + BOOST_CHECK_EQUAL(cru, fee.cru); |
| 61 | + BOOST_CHECK_EQUAL(endpoint, fee.endpoint); |
| 62 | + BOOST_CHECK_EQUAL(link, fee.link); |
| 63 | + BOOST_CHECK_EQUAL(userLogic, fee.userLogic); |
| 64 | + |
| 65 | + // RDH v4 checks |
| 66 | + rdh4.feeId = feeID; |
| 67 | + cru = getCRU(rdh4); |
| 68 | + link = getLink(rdh4); |
| 69 | + endpoint = getEndPoint(rdh4); |
| 70 | + userLogic = isFromUserLogic(rdh4); |
| 71 | + |
| 72 | + BOOST_CHECK_EQUAL(feeID, fee.feeID); |
| 73 | + BOOST_CHECK_EQUAL(cru, fee.cru); |
| 74 | + BOOST_CHECK_EQUAL(endpoint, fee.endpoint); |
| 75 | + BOOST_CHECK_EQUAL(link, fee.link); |
| 76 | + BOOST_CHECK_EQUAL(userLogic, fee.userLogic); |
| 77 | + |
| 78 | + // RDH v5 checks |
| 79 | + rdh5.feeId = feeID; |
| 80 | + cru = getCRU(rdh5); |
| 81 | + link = getLink(rdh5); |
| 82 | + endpoint = getEndPoint(rdh5); |
| 83 | + userLogic = isFromUserLogic(rdh5); |
| 84 | + |
| 85 | + BOOST_CHECK_EQUAL(feeID, fee.feeID); |
| 86 | + BOOST_CHECK_EQUAL(cru, fee.cru); |
| 87 | + BOOST_CHECK_EQUAL(endpoint, fee.endpoint); |
| 88 | + BOOST_CHECK_EQUAL(link, fee.link); |
| 89 | + BOOST_CHECK_EQUAL(userLogic, fee.userLogic); |
| 90 | + |
| 91 | + // RDH v6 checks |
| 92 | + rdh6.feeId = feeID; |
| 93 | + cru = getCRU(rdh6); |
| 94 | + link = getLink(rdh6); |
| 95 | + endpoint = getEndPoint(rdh6); |
| 96 | + userLogic = isFromUserLogic(rdh6); |
| 97 | + |
| 98 | + BOOST_CHECK_EQUAL(feeID, fee.feeID); |
| 99 | + BOOST_CHECK_EQUAL(cru, fee.cru); |
| 100 | + BOOST_CHECK_EQUAL(endpoint, fee.endpoint); |
| 101 | + BOOST_CHECK_EQUAL(link, fee.link); |
| 102 | + BOOST_CHECK_EQUAL(userLogic, fee.userLogic); |
| 103 | + } |
| 104 | +} |
| 105 | + |
| 106 | +} // namespace tpc |
| 107 | +} // namespace o2 |
0 commit comments