(*--------------------------------------------------------------------------- Copyright (c) 2025 Thomas Gazagnaire. All rights reserved. SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) (** SpaceOS E2E test harness — types and reporting. *) type config = { build_file : string option; run_file : string option; kernel : string option; output : string option; min_frames : int; timeout : float; } let default_config = { build_file = None; run_file = None; kernel = None; output = None; min_frames = 10; timeout = 60.; } type step_result = Pass of string | Fail of string let is_pass = function Pass _ -> true | Fail _ -> false let pp_result ppf = function | Pass msg -> Fmt.pf ppf " PASS %s" msg | Fail msg -> Fmt.pf ppf " FAIL %s" msg let exit_code results = if List.for_all is_pass results then 0 else 1 let report results = Fmt.pr "@.--- space-test results ---@."; List.iter (fun r -> Fmt.pr "%a@." pp_result r) results; let total = List.length results in let passed = List.length (List.filter is_pass results) in let failed = total - passed in Fmt.pr "@.%d/%d passed" passed total; if failed = 0 then Fmt.pr " — all good.@." else Fmt.pr " — %d failed.@." failed; exit_code results let check_frames ~received ~target = if received >= target then Pass (Fmt.str "received %d frames (target: %d)" received target) else Fail (Fmt.str "only %d frames received (target: %d)" received target) let check_exit_code n = if n = 0 then Pass "clean shutdown (exit code 0)" else Fail (Fmt.str "unclean shutdown (exit code %d)" n)