Project
Loading...
Searching...
No Matches
test_Task.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.
12#include "Framework/Task.h"
15#include "Framework/Logger.h"
16
17#define ASSERT_ERROR(condition) \
18 if ((condition) == false) { \
19 LOG(fatal) << R"(Test condition ")" #condition R"(" failed at )" << __FILE__ << ":" << __LINE__; \
20 }
21
22using namespace o2::framework;
23
24// This is a stateful task, where we send the state downstream.
25class ATask : public Task
26{
27 public:
28 ATask(int state)
29 : mSomeState{state} {}
30 void init(InitContext& ic) final
31 {
32 mSomeState += 1;
33 }
34 void run(ProcessingContext& pc) final
35 {
36 auto& result = pc.outputs().make<int>({"dummy"}, 1);
37 result[0] = mSomeState;
38 pc.services().get<o2::monitoring::Monitoring>().send({result[0], "output"});
39 pc.services().get<ControlService>().endOfStream();
40 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
41 }
42
43 private:
44 int mSomeState;
45};
46
47// This is a stateless sink, where we verify that the state
48// we receive from ATask is the one we expected.
49class BTask : public Task
50{
51 public:
52 void run(ProcessingContext& pc) final
53 {
54 auto result = pc.inputs().get<int>("in");
55 ASSERT_ERROR(result == 2);
56 pc.services().get<o2::monitoring::Monitoring>().send({result, "input"});
57 }
58
60 {
61 eos.services().get<ControlService>().readyToQuit(QuitRequest::All);
62 }
63};
64
66{
67 return WorkflowSpec{
69 "producer",
70 Inputs{},
71 {
72 OutputSpec{{"dummy"}, "TST", "TEST"},
73 },
74 adaptFromTask<ATask>(1)},
76 "consumer",
77 Inputs{
78 InputSpec{"in", "TST", "TEST"},
79 },
80 {},
81 adaptFromTask<BTask>()}};
82}
benchmark::State & state
virtual void endOfStream(EndOfStreamContext &context)
This is invoked whenever we have an EndOfStream event.
Definition Task.h:43
GLuint64EXT * result
Definition glcorearb.h:5662
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DataProcessorSpec > WorkflowSpec
std::vector< InputSpec > Inputs
ATask(int state)
Definition test_Task.cxx:28
void run(ProcessingContext &pc) final
Definition test_Task.cxx:34
void init(InitContext &ic) final
Definition test_Task.cxx:30
void run(ProcessingContext &pc) final
Definition test_Task.cxx:52
void endOfStream(EndOfStreamContext &eos) final
This is invoked whenever we have an EndOfStream event.
Definition test_Task.cxx:59
#define ASSERT_ERROR(condition)
Definition test_Task.cxx:17
WorkflowSpec defineDataProcessing(ConfigContext const &)
This function hooks up the the workflow specifications into the DPL driver.
Definition test_Task.cxx:65