Project
Loading...
Searching...
No Matches
testRDHManip.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#define BOOST_TEST_MODULE Test MCHRaw RAWDataHeader
13#define BOOST_TEST_MAIN
14#define BOOST_TEST_DYN_LINK
15
16#include <boost/test/unit_test.hpp>
17#include "RDHManip.h"
20
21using namespace o2::mch::raw;
22
23std::vector<uint32_t> testBuffer32()
24{
25 std::vector<uint32_t> buffer(16);
26 int n{0};
27 for (int i = 0; i < 16; i++) {
28 buffer[i] = n | ((n + 1) << 8) | ((n + 2) << 16) | ((n + 3) << 24);
29 n += 4;
30 }
31 return buffer;
32}
33
34std::vector<std::byte> testBufferByte()
35{
36 std::vector<std::byte> buffer(64);
37 for (uint8_t i = 0; i < 64; i++) {
38 buffer[i] = std::byte{i};
39 }
40 return buffer;
41}
42
43BOOST_AUTO_TEST_SUITE(o2_mch_raw)
44
45BOOST_AUTO_TEST_SUITE(rawdataheader)
46
48{
51 rdh.word0 = 0x0706050403020100;
52 rdh.word1 = 0x0F0E0D0C0B0A0908;
53 rdh.word2 = 0x1716151413121110;
54 rdh.word3 = 0x1F1E1D1C1B1A1918;
55 rdh.word4 = 0x2726252423222120;
56 rdh.word5 = 0x2F2E2D2C2B2A2928;
57 rdh.word6 = 0x3736353433323130;
58 rdh.word7 = 0x3F3E3D3C3B3A3938;
59 return rdh;
60}
61
63{
64 auto rdh = getTestRDH(4);
65 std::vector<std::byte> buffer;
66 appendRDH(buffer, rdh);
67 auto tb = testBufferByte();
68 BOOST_CHECK_EQUAL(buffer.size(), tb.size());
69 BOOST_CHECK(std::equal(begin(buffer), end(buffer), begin(tb)));
70}
71
72BOOST_AUTO_TEST_CASE(CreateRDHFromBuffer8)
73{
74 auto buffer = testBufferByte();
75 auto rdh = createRDH(buffer, 4);
76 BOOST_CHECK_EQUAL(rdh.word0, 0x0706050403020100);
77 BOOST_CHECK_EQUAL(rdh.word1, 0x0F0E0D0C0B0A0908);
78 BOOST_CHECK_EQUAL(rdh.word2, 0x1716151413121110);
79 BOOST_CHECK_EQUAL(rdh.word3, 0x1F1E1D1C1B1A1918);
80 BOOST_CHECK_EQUAL(rdh.word4, 0x2726252423222120);
81 BOOST_CHECK_EQUAL(rdh.word5, 0x2F2E2D2C2B2A2928);
82 BOOST_CHECK_EQUAL(rdh.word6, 0x3736353433323130);
83 BOOST_CHECK_EQUAL(rdh.word7, 0x3F3E3D3C3B3A3938);
84}
85BOOST_AUTO_TEST_SUITE_END()
86BOOST_AUTO_TEST_SUITE_END()
int32_t i
Definition of the RAW Data Header.
uint32_t version
Definition RawData.h:8
GLdouble n
Definition glcorearb.h:1982
GLuint buffer
Definition glcorearb.h:655
GLuint GLuint end
Definition glcorearb.h:469
o2::header::RDHAny createRDH(gsl::span< const std::byte > buffer, int version)
Definition RDHManip.cxx:171
void appendRDH(std::vector< std::byte > &buffer, const o2::header::RDHAny &rdh)
Append bytes from RDH to the buffer.
Definition RDHManip.cxx:147
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
BOOST_AUTO_TEST_CASE(FlatHisto)
uint64_t word7
Definition RDHAny.h:37
uint64_t word6
Definition RDHAny.h:36
uint64_t word0
Definition RDHAny.h:30
uint64_t word1
Definition RDHAny.h:31
uint64_t word3
Definition RDHAny.h:33
uint64_t word2
Definition RDHAny.h:32
uint64_t word4
Definition RDHAny.h:34
uint64_t word5
Definition RDHAny.h:35
static void setVersion(H &rdh, uint8_t v, NOTPTR(H))
Definition RDHUtils.h:88
std::vector< uint32_t > testBuffer32()
std::vector< std::byte > testBufferByte()
o2::header::RDHAny getTestRDH(int version)
BOOST_CHECK(tree)
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())