mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2026-11-25 21:21:37 +00:00
fix(test): join threads and end the device on an early return
- an ASSERT_* between thread start and join() returned with a joinable std::thread, and its destructor called std::terminate() - the PluginServices fixture ended the device only from Idle; after a failure in another state, the join waited until the ctest timeout - use StateMachineThread in the Transitions tests and in the fixture, and JoiningThread in Region.LockOrder Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
|
||||
namespace fair::mq::test
|
||||
{
|
||||
@@ -28,9 +27,8 @@ struct PluginServices : ::testing::Test {
|
||||
: mConfig()
|
||||
, mDevice()
|
||||
, mServices(mConfig, mDevice)
|
||||
, fRunStateMachineThread()
|
||||
, fStateMachineThread(mDevice)
|
||||
{
|
||||
fRunStateMachineThread = std::thread(&fair::mq::Device::RunStateMachine, &mDevice);
|
||||
mDevice.SetTransport("zeromq");
|
||||
}
|
||||
|
||||
@@ -39,15 +37,13 @@ struct PluginServices : ::testing::Test {
|
||||
if (mDevice.GetCurrentState() == State::Idle) {
|
||||
Control(mDevice, Cycle::ToDeviceReadyAndBack);
|
||||
}
|
||||
if (fRunStateMachineThread.joinable()) {
|
||||
fRunStateMachineThread.join();
|
||||
}
|
||||
// fStateMachineThread drives the device to Exiting from any other state
|
||||
}
|
||||
|
||||
ProgOptions mConfig;
|
||||
Device mDevice;
|
||||
mq::PluginServices mServices;
|
||||
std::thread fRunStateMachineThread;
|
||||
StateMachineThread fStateMachineThread;
|
||||
};
|
||||
|
||||
} // namespace fair::mq::test
|
||||
|
||||
Reference in New Issue
Block a user