Project
Loading...
Searching...
No Matches
test_ControlServiceHelpers.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#include "../src/ControlServiceHelpers.h"
13#include <catch_amalgamated.hpp>
14#include <regex>
15#include <string_view>
16
17TEST_CASE("TestControlServiceHelper")
18{
19 using namespace o2::framework;
20 std::match_results<std::string_view::const_iterator> match;
21 REQUIRE(ControlServiceHelpers::parseControl("foo", match) == false);
22 std::match_results<std::string_view::const_iterator> match2;
23 std::string sv = "CONTROL_ACTION: READY_TO_QUIT_ME";
24 REQUIRE(ControlServiceHelpers::parseControl(sv, match2) == true);
25 REQUIRE(match2[1].str() == "QUIT");
26 REQUIRE(match2[2].str() == "ME");
27 std::string sv2 = " dsca CONTROL_ACTION: READY_TO_QUIT_ME";
28 REQUIRE(ControlServiceHelpers::parseControl(sv2, match2) == true);
29 REQUIRE(match2[1].str() == "QUIT");
30 REQUIRE(match2[2].str() == "ME");
31 const static std::regex controlRE2("^(NOTIFY_STREAMING_STATE) (IDLE|STREAMING|EOS)", std::regex::optimize);
32 const static std::regex controlRE3("^(NOTIFY_DEVICE_STATE) ([A-Z ]*)", std::regex::optimize);
33 std::string sv3 = " dsca CONTROL_ACTION: NOTIFY_STREAMING_STATE IDLE";
34 REQUIRE(ControlServiceHelpers::parseControl(sv3, match2) == true);
35 REQUIRE(match2[1].str() == "NOTIFY_STREAMING_STATE");
36 REQUIRE(match2[2].str() == "IDLE");
37 std::string_view sv4 = " dsca CONTROL_ACTION: NOTIFY_STREAMING_STATE IDLE";
38 REQUIRE(ControlServiceHelpers::parseControl(sv4, match2) == true);
39 REQUIRE(match2[1].str() == "NOTIFY_STREAMING_STATE");
40 REQUIRE(match2[2].str() == "IDLE");
41 std::string_view sv5 = " asdsca CONTROL_ACTION: NOTIFY_DEVICE_STATE STOP";
42 REQUIRE(ControlServiceHelpers::parseControl(sv5, match2) == true);
43 REQUIRE(match2[1].str() == "NOTIFY_DEVICE_STATE");
44 REQUIRE(match2[2].str() == "STOP");
45 std::string_view sv6 = " asdsca CONTROL_ACTION: ";
46 REQUIRE(ControlServiceHelpers::parseControl(sv6, match2) == false);
47}
bool match(const std::vector< std::string > &queries, const char *pattern)
Definition dcs-ccdb.cxx:229
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
TEST_CASE("TestControlServiceHelper")
const std::string str