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:
@@ -6,13 +6,14 @@
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include "../helper/ControlDevice.h"
|
||||
|
||||
#include <fairmq/Device.h>
|
||||
#include <fairlogger/Logger.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
#include <system_error>
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -23,23 +24,23 @@ using namespace fair::mq;
|
||||
TEST(Transitions, InvalidChangeState)
|
||||
{
|
||||
Device device;
|
||||
thread t([&] { device.RunStateMachine(); });
|
||||
test::StateMachineThread t(device);
|
||||
|
||||
ASSERT_FALSE(device.ChangeState(Transition::Connect));
|
||||
|
||||
ASSERT_TRUE(device.ChangeState(Transition::End));
|
||||
if (t.joinable()) { t.join(); }
|
||||
t.Join();
|
||||
}
|
||||
|
||||
TEST(Transitions, InvalidChangeStateOrThrow)
|
||||
{
|
||||
Device device;
|
||||
thread t([&] { device.RunStateMachine(); });
|
||||
test::StateMachineThread t(device);
|
||||
|
||||
ASSERT_THROW(device.ChangeStateOrThrow(Transition::Connect), std::system_error);
|
||||
|
||||
ASSERT_NO_THROW(device.ChangeStateOrThrow(Transition::End));
|
||||
if (t.joinable()) { t.join(); }
|
||||
t.Join();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user