End-to-end test harness for the SpaceOS pipeline
at main 55 lines 1.7 kB view raw
1(*--------------------------------------------------------------------------- 2 Copyright (c) 2025 Thomas Gazagnaire. All rights reserved. 3 SPDX-License-Identifier: ISC 4 ---------------------------------------------------------------------------*) 5 6(** SpaceOS E2E test harness — types and reporting. *) 7 8type config = { 9 build_file : string option; 10 run_file : string option; 11 kernel : string option; 12 output : string option; 13 min_frames : int; 14 timeout : float; 15} 16 17let default_config = 18 { 19 build_file = None; 20 run_file = None; 21 kernel = None; 22 output = None; 23 min_frames = 10; 24 timeout = 60.; 25 } 26 27type step_result = Pass of string | Fail of string 28 29let is_pass = function Pass _ -> true | Fail _ -> false 30 31let pp_result ppf = function 32 | Pass msg -> Fmt.pf ppf " PASS %s" msg 33 | Fail msg -> Fmt.pf ppf " FAIL %s" msg 34 35let exit_code results = if List.for_all is_pass results then 0 else 1 36 37let report results = 38 Fmt.pr "@.--- space-test results ---@."; 39 List.iter (fun r -> Fmt.pr "%a@." pp_result r) results; 40 let total = List.length results in 41 let passed = List.length (List.filter is_pass results) in 42 let failed = total - passed in 43 Fmt.pr "@.%d/%d passed" passed total; 44 if failed = 0 then Fmt.pr " — all good.@." 45 else Fmt.pr " — %d failed.@." failed; 46 exit_code results 47 48let check_frames ~received ~target = 49 if received >= target then 50 Pass (Fmt.str "received %d frames (target: %d)" received target) 51 else Fail (Fmt.str "only %d frames received (target: %d)" received target) 52 53let check_exit_code n = 54 if n = 0 then Pass "clean shutdown (exit code 0)" 55 else Fail (Fmt.str "unclean shutdown (exit code %d)" n)