18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-19 13:26:08 +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:
jerrrrycho
2026-11-08 11:33:36 +01:00
parent 14d25520f3
commit 03a417c7b0
11 changed files with 210 additions and 35 deletions

View File

@@ -468,6 +468,15 @@ bool global_settings::ConfigParseTest(cParser& Parser, std::string_view const To
return true;
}
if (Token == "test.wall_timeout")
{
double value{ 0.0 };
ParseOne(Parser, value);
if (false == test.wall_timeout_from_command_line)
test.wall_timeout = std::max(0.0, value);
return true;
}
if (Token == "test.standstill")
{
ParseOne(Parser, test.standstill);
@@ -1786,6 +1795,9 @@ global_settings::export_as_text( std::ostream &Output ) const {
// TODO: export fpslimit
export_as_text( Output, "randomseed", Global.random_seed );
export_as_text( Output, "test.timeout", test.timeout );
if( test.wall_timeout.has_value() ) {
export_as_text( Output, "test.wall_timeout", *test.wall_timeout );
}
export_as_text( Output, "test.standstill", test.standstill );
export_as_text( Output, "test.pass_on_standstill", test.pass_on_standstill );
export_as_text( Output, "test.fail_if_stop_overran", test.fail_if_stop_overran );