test: parameterize the device state tests by state and control

- Add test::StateParam (state, control mode, stdin input) and
  WithControls() for INSTANTIATE_TEST_SUITE_P()
- Turn the 60 TEST() copies in the Exceptions, ErrorState, Signals and
  WaitFor files into one TEST_P() each
- The test names change, e.g. Exceptions.interactive_InRun is now
  Exceptions.Throw/interactive_Run, Signal_SIGINT.* is Signals.RaiseSIGINT/*
  and ErrorState.OrphanMessages is OrphanMessages.shmem

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-11-03 14:42:38 +00:00
committed by Dennis Klein
parent 5da5a35b4d
commit 8ff2214f9c
5 changed files with 114 additions and 309 deletions

View File

@@ -7,6 +7,7 @@
********************************************************************************/
#include <helper/Devices.h>
#include <helper/StateParam.h>
#include <gtest/gtest.h>
@@ -19,45 +20,20 @@ namespace
using namespace std;
using namespace fair::mq::test;
void RunWaitFor(string const& state, string const& control)
using WaitFor = StateTest;
TEST_P(WaitFor, Interrupt)
{
RunOptions options;
options.control = control;
options.control = GetParam().control;
options.signal = SIGINT;
options.extraArgs = "--severity debug";
auto const results = RunDevices({{"waitfor_" + state + "_"}}, options);
auto const results = RunDevices({{"waitfor_" + GetParam().state + "_"}}, options);
EXPECT_TRUE(ExitedWith(results.at(0), 0, "Sleeping Done. Interrupted."));
}
TEST(WaitFor, static_InPreRun)
{
RunWaitFor("PreRun", "static");
}
TEST(WaitFor, static_InRun)
{
RunWaitFor("Run", "static");
}
TEST(WaitFor, static_InPostRun)
{
RunWaitFor("PostRun", "static");
}
TEST(WaitFor, interactive_InPreRun)
{
RunWaitFor("PreRun", "interactive");
}
TEST(WaitFor, interactive_InRun)
{
RunWaitFor("Run", "interactive");
}
TEST(WaitFor, interactive_InPostRun)
{
RunWaitFor("PostRun", "interactive");
}
// The device waits (and SIGINT interrupts the wait) only in these states.
INSTANTIATE_TEST_SUITE_P(, WaitFor, WithControls({"PreRun", "Run", "PostRun"}), StateParamName());
} // namespace