mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-18 21:06:00 +01:00
feat(simulation): a real time watchdog ends a test run that hangs
A test run that hung, in the loading or anywhere else, waited until whoever started it killed it. A watchdog thread now ends a run still going test.wall_timeout seconds of real time after the start of the simulator, loading included: it says `test: timeout ... still running after N s of real time` and quits with the timeout code, whatever the main thread is doing, with no dialog. A test that has ended but whose simulator doesn't close ends with its own result. The limit is test.wall_timeout (settings, the scenery's config block) or --test-wall-timeout, which wins. Not given, it is test.timeout + 600 s: ten minutes for the loading, and a simulation that runs at least as fast as real time is never cut short. test.timeout 0 means no watchdog unless the limit is given; test.wall_timeout 0 turns it off. run.py passes the case's timeout as --test-wall-timeout and kills a simulator only 30 s after it. A timeout from the watchdog counts as wall_timeout there, so a run that hung doesn't pass a case expecting the simulation time to run out; test_mode_wall_timeout ends while loading on a limit of 2 s.
This commit is contained in:
@@ -1166,6 +1166,11 @@ int eu07_application::init_settings(int Argc, char *Argv[])
|
||||
Global.test.timeout = *testcommandline.timeout;
|
||||
Global.test.timeout_from_command_line = true;
|
||||
}
|
||||
if (testcommandline.wall_timeout.has_value())
|
||||
{
|
||||
Global.test.wall_timeout = testcommandline.wall_timeout;
|
||||
Global.test.wall_timeout_from_command_line = true;
|
||||
}
|
||||
|
||||
fs::path iniPath = user_config_path("eu07.ini");
|
||||
|
||||
@@ -1231,7 +1236,7 @@ int eu07_application::init_settings(int Argc, char *Argv[])
|
||||
// integration test: the scenery runs unattended and the exit code is the result (eu07/maszyna#541),
|
||||
// taken from the command line above
|
||||
}
|
||||
else if (token == "--test-timeout")
|
||||
else if (token == "--test-timeout" || token == "--test-wall-timeout")
|
||||
{
|
||||
// taken from the command line above, with its value
|
||||
++i;
|
||||
@@ -1253,7 +1258,7 @@ int eu07_application::init_settings(int Argc, char *Argv[])
|
||||
<< " [-edit [sceneryfilepath]]"
|
||||
<< " [-seed number|word]"
|
||||
<< " [-ini settingsfile]"
|
||||
<< " [--test [--test-timeout seconds]]" << std::endl;
|
||||
<< " [--test [--test-timeout seconds] [--test-wall-timeout seconds]]" << std::endl;
|
||||
simulation::test().conclude(simulation::test_result::error, std::format("unknown command line argument {}", token));
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user