forked from mcoquet642/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_CompletionPolicy.cxx
More file actions
64 lines (54 loc) · 2.35 KB
/
test_CompletionPolicy.cxx
File metadata and controls
64 lines (54 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#define BOOST_TEST_MODULE Test Framework CompletionPolicy
#define BOOST_TEST_MAIN
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include "Framework/CompletionPolicy.h"
#include "Framework/CompletionPolicyHelpers.h"
#include "Headers/DataHeader.h"
#include "Headers/NameHeader.h"
#include "Framework/CompletionPolicy.h"
#include "Framework/InputSpan.h"
#include "Headers/Stack.h"
using namespace o2::framework;
BOOST_AUTO_TEST_CASE(TestCompletionPolicy)
{
std::ostringstream oss;
oss << CompletionPolicy::CompletionOp::Consume
<< CompletionPolicy::CompletionOp::Process
<< CompletionPolicy::CompletionOp::Wait
<< CompletionPolicy::CompletionOp::Discard;
BOOST_REQUIRE_EQUAL(oss.str(), "consumeprocesswaitdiscard");
}
BOOST_AUTO_TEST_CASE(TestCompletionPolicy_callback)
{
o2::header::Stack stack{o2::header::DataHeader{"SOMEDATA", "TST", 0, 0}, o2::header::NameHeader<9>{"somename"}};
auto matcher = [](auto const&) {
return true;
};
auto callback = [&stack](InputSpan const& inputRefs) {
for (auto const& ref : inputRefs) {
auto const* header = CompletionPolicyHelpers::getHeader<o2::header::DataHeader>(ref);
BOOST_CHECK_EQUAL(header, reinterpret_cast<o2::header::DataHeader*>(stack.data()));
BOOST_CHECK(CompletionPolicyHelpers::getHeader<o2::header::NameHeader<9>>(ref) != nullptr);
BOOST_CHECK(CompletionPolicyHelpers::getHeader<o2::header::NameHeader<9>*>(ref) != nullptr);
}
return CompletionPolicy::CompletionOp::Consume;
};
std::vector<CompletionPolicy> policies;
policies.emplace_back("test", matcher, callback);
CompletionPolicy::InputSetElement ref{nullptr, reinterpret_cast<const char*>(stack.data()), nullptr};
InputSpan const& inputs{[&ref](size_t) { return ref; }, 1};
for (auto& policy : policies) {
policy.callback(inputs);
}
}