mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 09:31:45 +00:00
test: Consolidate some device control logic
This commit is contained in:
committed by
Dennis Klein
parent
435d07eaf9
commit
84de22f80b
@@ -1,17 +1,21 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2017 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* Copyright (C) 2017-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "../helper/ControlDevice.h"
|
||||
|
||||
#include <fairmq/Plugin.h>
|
||||
#include <fairmq/PluginServices.h>
|
||||
#include <fairmq/tools/Version.h>
|
||||
#include <fairmq/Device.h>
|
||||
#include <fairmq/ProgOptions.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
@@ -27,19 +31,7 @@ using namespace fair::mq;
|
||||
auto control(Device& device) -> void
|
||||
{
|
||||
device.SetTransport("zeromq");
|
||||
|
||||
device.ChangeState(Transition::InitDevice);
|
||||
device.WaitForState(State::InitializingDevice);
|
||||
device.ChangeState(Transition::CompleteInit);
|
||||
device.WaitForState(State::Initialized);
|
||||
device.ChangeState(Transition::Bind);
|
||||
device.WaitForState(State::Bound);
|
||||
device.ChangeState(Transition::Connect);
|
||||
device.WaitForState(State::DeviceReady);
|
||||
device.ChangeState(Transition::ResetDevice);
|
||||
device.WaitForState(State::Idle);
|
||||
|
||||
device.ChangeState(Transition::End);
|
||||
test::Control(device, test::Cycle::ToDeviceReadyAndBack);
|
||||
}
|
||||
|
||||
TEST(Plugin, Operators)
|
||||
@@ -52,7 +44,7 @@ TEST(Plugin, Operators)
|
||||
Plugin p3{"file", {1, 0, 0}, "Foo Bar <foo.bar@test.net>", "https://git.test.net/file.git", &services};
|
||||
EXPECT_EQ(p1, p2);
|
||||
EXPECT_NE(p1, p3);
|
||||
thread t(control, std::ref(device));
|
||||
thread t([&]() { control(device); });
|
||||
device.RunStateMachine();
|
||||
if (t.joinable()) {
|
||||
t.join();
|
||||
@@ -68,7 +60,7 @@ TEST(Plugin, OstreamOperators)
|
||||
stringstream ss;
|
||||
ss << p1;
|
||||
EXPECT_EQ(ss.str(), string{"'dds', version '1.0.0', maintainer 'Foo Bar <foo.bar@test.net>', homepage 'https://git.test.net/dds.git'"});
|
||||
thread t(control, std::ref(device));
|
||||
thread t([&]() { control(device); });
|
||||
device.RunStateMachine();
|
||||
if (t.joinable()) {
|
||||
t.join();
|
||||
|
Reference in New Issue
Block a user