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>
@@ -18,104 +19,19 @@ namespace
using namespace std;
using namespace fair::mq::test;
void RunExceptionIn(string const& state, string const& control, string const& input = "")
using Exceptions = StateTest;
TEST_P(Exceptions, Throw)
{
auto const& state = GetParam().state;
RunOptions options;
options.control = control;
options.input = input;
options.control = GetParam().control;
options.input = GetParam().Input();
auto const results = RunDevices({{"exceptions_" + state + "_"}}, options);
EXPECT_TRUE(ExitedWith(results.at(0), 1, "exception in " + state + "()"));
}
TEST(Exceptions, static_InInit)
{
RunExceptionIn("Init", "static");
}
TEST(Exceptions, static_InBind)
{
RunExceptionIn("Bind", "static");
}
TEST(Exceptions, static_InConnect)
{
RunExceptionIn("Connect", "static");
}
TEST(Exceptions, static_InInitTask)
{
RunExceptionIn("InitTask", "static");
}
TEST(Exceptions, static_InPreRun)
{
RunExceptionIn("PreRun", "static");
}
TEST(Exceptions, static_InRun)
{
RunExceptionIn("Run", "static");
}
TEST(Exceptions, static_InPostRun)
{
RunExceptionIn("PostRun", "static");
}
TEST(Exceptions, static_InResetTask)
{
RunExceptionIn("ResetTask", "static");
}
TEST(Exceptions, static_InReset)
{
RunExceptionIn("Reset", "static");
}
TEST(Exceptions, interactive_InInit)
{
RunExceptionIn("Init", "interactive");
}
TEST(Exceptions, interactive_InBind)
{
RunExceptionIn("Bind", "interactive");
}
TEST(Exceptions, interactive_InConnect)
{
RunExceptionIn("Connect", "interactive");
}
TEST(Exceptions, interactive_InInitTask)
{
RunExceptionIn("InitTask", "interactive");
}
TEST(Exceptions, interactive_InPreRun)
{
RunExceptionIn("PreRun", "interactive");
}
TEST(Exceptions, interactive_InRun)
{
RunExceptionIn("Run", "interactive");
}
TEST(Exceptions, interactive_InPostRun)
{
RunExceptionIn("PostRun", "interactive");
}
TEST(Exceptions, interactive_InResetTask)
{
RunExceptionIn("ResetTask", "interactive", "q");
}
TEST(Exceptions, interactive_InReset)
{
RunExceptionIn("Reset", "interactive", "q");
}
INSTANTIATE_TEST_SUITE_P(, Exceptions, WithControls(HookStates()), StateParamName());
} // namespace