18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-19 00:35:59 +01:00

feat(simulation): the test mode's exit codes keep clear of 1 and 3

1 is what a process killed with TerminateProcess (and the plain failure of most
programs) ends with, 3 what abort() ends with on Windows, so a fail or a timeout
couldn't be told from a run that was killed or blew up. The codes other than
pass now are 10 fail, 11 signal passed at danger, 12 timeout, 13 standstill and
14 error: none of them a code a process gets on its own, neither the shells'
126-127 nor 128 + a signal number on Linux. pass stays 0.
This commit is contained in:
jerrrrycho
2026-11-08 11:21:30 +01:00
parent 486a714f52
commit baf6bc2a20
4 changed files with 48 additions and 21 deletions

View File

@@ -3,9 +3,10 @@
#include "simulation/simulationtestrules.h"
#include <array>
#include <vector>
// the test mode of the simulator (eu07 --test, eu07/maszyna#541): its command line and end conditions
// the test mode of the simulator (eu07 --test, eu07/maszyna#541): its exit codes, command line and end conditions
namespace {
@@ -37,6 +38,27 @@ std::optional<simulation::test_verdict> run(simulation::test_progress &Progress,
} // namespace
TEST_CASE("test mode: the exit codes keep clear of the ones of a killed or aborted process")
{
std::array const results{test_result::pass, test_result::fail, test_result::signal_passed_at_danger, test_result::timeout, test_result::standstill, test_result::error};
for (auto const result : results)
{
auto const code{static_cast<int>(result)};
CAPTURE(code);
CHECK(code != 1); // TerminateProcess, most programs' failure
CHECK(code != 3); // abort() on Windows
CHECK(code < 126); // shells, signals on Linux
CHECK(simulation::to_string(result) != "unknown");
}
// the codes are public: scripts and CI read them
CHECK(static_cast<int>(test_result::pass) == 0);
CHECK(static_cast<int>(test_result::fail) == 10);
CHECK(static_cast<int>(test_result::signal_passed_at_danger) == 11);
CHECK(static_cast<int>(test_result::timeout) == 12);
CHECK(static_cast<int>(test_result::standstill) == 13);
CHECK(static_cast<int>(test_result::error) == 14);
}
TEST_CASE("test mode: seconds on the command line are a number, not negative")
{
CHECK(simulation::parse_seconds("240") == 240.0);