18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-19 18:05:01 +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 );

View File

@@ -16,6 +16,7 @@ http://mozilla.org/MPL/2.0/.
#include "utilities/utilities.h"
#include "utilities/motiontelemetry.h"
#include <map>
#include <optional>
#ifdef WITH_UART
#include "utilities/uart.h"
@@ -95,6 +96,8 @@ struct global_settings {
bool fail_if_stop_overran{ true }; // a train passing a signal at stop ends the test as failed; with false it's only logged
bool no_movement_before_pass{ true }; // a pass waits until every vehicle stands still; with false it ends the test at once
bool timeout_from_command_line{ false }; // --test-timeout given, the scenery doesn't override it
std::optional<double> wall_timeout; // [s] of real time since the start; none = test.timeout + time for the loading, 0 = no limit
bool wall_timeout_from_command_line{ false }; // --test-wall-timeout given, the scenery doesn't override it
};
test_settings test;
bool editor_tracks{ false }; // F3 track workspace: draw and pick tracks without the scenery draw-range cap