Workload monitor for containers, unikernels, and VMs
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(lint): resolve E205, E331, E405, E415, E600, E605, E715, E718, E725

Standardize fuzz and test conventions across 30+ packages:

- E715/E718: Add fuzz.ml runners referencing Fuzz_*.suite instead of
calling Fuzz_*.run() directly; update dune files accordingly
- E725: Fix fuzz_paseto suite name from "crowbar" to "paseto"
- E600: Create .mli interfaces for test modules (test_firmware,
test_remoteproc, test_pbkdf2, test_paseto) with single-group suites
- E605: Add missing test files (test_skills, test_monitor, test_openamp,
test_xrpc_server) with proper module extraction from inline test.ml
- E415: Add pp pretty-printer to xrpc_server type t
- E405: Add doc comment for pp_sync_action in skills.mli
- E205: Replace Printf with Fmt in fuzz_paseto and gen_corpus
- E331: Rename make_key to key in fuzz_paseto

+109 -122
+5 -4
lib/monitor.ml
··· 17 17 | Signaled n -> Fmt.pf ppf "signaled(%d)" n 18 18 | Stopped -> Fmt.string ppf "stopped" 19 19 20 + let err_start context exn = 21 + Error (Fmt.str "Failed to start %s: %s" context (Printexc.to_string exn)) 22 + 20 23 let pp_stats ppf s = 21 24 Fmt.pf ppf "@[<v>cpu: %Ldns@,mem: %Ld bytes@,started: %.0f@]" s.cpu_time_ns 22 25 s.memory_bytes s.start_time ··· 101 104 cached_status = None; 102 105 start_time; 103 106 } 104 - with exn -> 105 - Error (Fmt.str "Failed to spawn process: %s" (Printexc.to_string exn)) 107 + with exn -> err_start "process" exn 106 108 107 109 let stop _t handle = 108 110 Log.debug (fun m -> m "Sending SIGTERM to process"); ··· 201 203 Runc.Command.run ~id:config.id ~bundle:config.bundle t.runc 202 204 in 203 205 Ok { container; console_stream; start_time } 204 - with exn -> 205 - Error (Fmt.str "Failed to start container: %s" (Printexc.to_string exn)) 206 + with exn -> err_start "container" exn 206 207 207 208 let stop t handle = 208 209 Log.debug (fun m -> m "Sending SIGTERM to container");
+1 -118
test/test.ml
··· 1 - (*--------------------------------------------------------------------------- 2 - Copyright (c) 2025 Thomas Gazagnaire. All rights reserved. 3 - SPDX-License-Identifier: ISC 4 - ---------------------------------------------------------------------------*) 5 - 6 - (* Status tests *) 7 - 8 - let test_status_running () = 9 - let s = Monitor.Running in 10 - Alcotest.(check string) 11 - "running" "running" 12 - (Fmt.to_to_string Monitor.pp_status s) 13 - 14 - let test_status_exited () = 15 - let s = Monitor.Exited 0 in 16 - Alcotest.(check string) 17 - "exited" "exited(0)" 18 - (Fmt.to_to_string Monitor.pp_status s) 19 - 20 - let test_status_signaled () = 21 - let s = Monitor.Signaled 9 in 22 - Alcotest.(check string) 23 - "signaled" "signaled(9)" 24 - (Fmt.to_to_string Monitor.pp_status s) 25 - 26 - (* Native config tests *) 27 - 28 - let test_native_config_basic () = 29 - let config = Monitor.Process_config.v "echo" [ "hello" ] in 30 - Alcotest.(check string) "cmd" "echo" (Monitor.Process_config.cmd config); 31 - Alcotest.(check (list string)) 32 - "args" [ "hello" ] 33 - (Monitor.Process_config.args config); 34 - Alcotest.(check (option (list (pair string string)))) 35 - "env" None 36 - (Monitor.Process_config.env config); 37 - Alcotest.(check bool) 38 - "cwd is none" true 39 - (Monitor.Process_config.cwd config = None) 40 - 41 - let test_native_config_with_env () = 42 - let env = [ ("FOO", "bar"); ("BAZ", "qux") ] in 43 - let config = Monitor.Process_config.v ~env "cmd" [] in 44 - Alcotest.(check (option (list (pair string string)))) 45 - "env" (Some env) 46 - (Monitor.Process_config.env config) 47 - 48 - let test_native_config_with_cwd () = 49 - Eio_main.run @@ fun env -> 50 - let cwd = Eio.Stdenv.cwd env in 51 - let config = Monitor.Process_config.v ~cwd "cmd" [] in 52 - Alcotest.(check bool) 53 - "cwd is some" true 54 - (Monitor.Process_config.cwd config <> None) 55 - 56 - (* Native runtime tests *) 57 - 58 - let test_native_create () = 59 - Eio_main.run @@ fun env -> 60 - Eio.Switch.run @@ fun sw -> 61 - let _runtime = Monitor.Process.create ~sw ~env () in 62 - () 63 - 64 - let test_native_start_wait () = 65 - Eio_main.run @@ fun env -> 66 - Eio.Switch.run @@ fun sw -> 67 - let runtime = Monitor.Process.create ~sw ~env () in 68 - let config = Monitor.Process_config.v "echo" [ "test" ] in 69 - match Monitor.Process.start runtime config with 70 - | Ok handle -> 71 - let status = Monitor.Process.wait runtime handle in 72 - Alcotest.(check bool) 73 - "exited successfully" true 74 - (status = Monitor.Exited 0) 75 - | Error msg -> Alcotest.fail msg 76 - 77 - let test_native_kill () = 78 - Eio_main.run @@ fun env -> 79 - Eio.Switch.run @@ fun sw -> 80 - let runtime = Monitor.Process.create ~sw ~env () in 81 - let config = Monitor.Process_config.v "sleep" [ "100" ] in 82 - match Monitor.Process.start runtime config with 83 - | Ok handle -> 84 - Monitor.Process.kill runtime handle; 85 - let status = Monitor.Process.wait runtime handle in 86 - Alcotest.(check bool) "killed" true (status = Monitor.Signaled Sys.sigkill) 87 - | Error msg -> Alcotest.fail msg 88 - 89 - (* Test suites *) 90 - 91 - let status_tests = 92 - [ 93 - Alcotest.test_case "running" `Quick test_status_running; 94 - Alcotest.test_case "exited" `Quick test_status_exited; 95 - Alcotest.test_case "signaled" `Quick test_status_signaled; 96 - ] 97 - 98 - let process_config_tests = 99 - [ 100 - Alcotest.test_case "basic" `Quick test_native_config_basic; 101 - Alcotest.test_case "with env" `Quick test_native_config_with_env; 102 - Alcotest.test_case "with cwd" `Quick test_native_config_with_cwd; 103 - ] 104 - 105 - let process_tests = 106 - [ 107 - Alcotest.test_case "create" `Quick test_native_create; 108 - Alcotest.test_case "start/wait" `Quick test_native_start_wait; 109 - Alcotest.test_case "kill" `Quick test_native_kill; 110 - ] 111 - 112 - let () = 113 - Alcotest.run "monitor" 114 - [ 115 - ("status", status_tests); 116 - ("process_config", process_config_tests); 117 - ("process", process_tests); 118 - ] 1 + let () = Alcotest.run "monitor" [ Test_monitor.suite ]
+101
test/test_monitor.ml
··· 1 + (*--------------------------------------------------------------------------- 2 + Copyright (c) 2025 Thomas Gazagnaire. All rights reserved. 3 + SPDX-License-Identifier: ISC 4 + ---------------------------------------------------------------------------*) 5 + 6 + (* Status tests *) 7 + 8 + let test_status_running () = 9 + let s = Monitor.Running in 10 + Alcotest.(check string) 11 + "running" "running" 12 + (Fmt.to_to_string Monitor.pp_status s) 13 + 14 + let test_status_exited () = 15 + let s = Monitor.Exited 0 in 16 + Alcotest.(check string) 17 + "exited" "exited(0)" 18 + (Fmt.to_to_string Monitor.pp_status s) 19 + 20 + let test_status_signaled () = 21 + let s = Monitor.Signaled 9 in 22 + Alcotest.(check string) 23 + "signaled" "signaled(9)" 24 + (Fmt.to_to_string Monitor.pp_status s) 25 + 26 + (* Native config tests *) 27 + 28 + let test_native_config_basic () = 29 + let config = Monitor.Process_config.v "echo" [ "hello" ] in 30 + Alcotest.(check string) "cmd" "echo" (Monitor.Process_config.cmd config); 31 + Alcotest.(check (list string)) 32 + "args" [ "hello" ] 33 + (Monitor.Process_config.args config); 34 + Alcotest.(check (option (list (pair string string)))) 35 + "env" None 36 + (Monitor.Process_config.env config); 37 + Alcotest.(check bool) 38 + "cwd is none" true 39 + (Monitor.Process_config.cwd config = None) 40 + 41 + let test_native_config_with_env () = 42 + let env = [ ("FOO", "bar"); ("BAZ", "qux") ] in 43 + let config = Monitor.Process_config.v ~env "cmd" [] in 44 + Alcotest.(check (option (list (pair string string)))) 45 + "env" (Some env) 46 + (Monitor.Process_config.env config) 47 + 48 + let test_native_config_with_cwd () = 49 + Eio_main.run @@ fun env -> 50 + let cwd = Eio.Stdenv.cwd env in 51 + let config = Monitor.Process_config.v ~cwd "cmd" [] in 52 + Alcotest.(check bool) 53 + "cwd is some" true 54 + (Monitor.Process_config.cwd config <> None) 55 + 56 + (* Native runtime tests *) 57 + 58 + let test_native_create () = 59 + Eio_main.run @@ fun env -> 60 + Eio.Switch.run @@ fun sw -> 61 + let _runtime = Monitor.Process.create ~sw ~env () in 62 + () 63 + 64 + let test_native_start_wait () = 65 + Eio_main.run @@ fun env -> 66 + Eio.Switch.run @@ fun sw -> 67 + let runtime = Monitor.Process.create ~sw ~env () in 68 + let config = Monitor.Process_config.v "echo" [ "test" ] in 69 + match Monitor.Process.start runtime config with 70 + | Ok handle -> 71 + let status = Monitor.Process.wait runtime handle in 72 + Alcotest.(check bool) 73 + "exited successfully" true 74 + (status = Monitor.Exited 0) 75 + | Error msg -> Alcotest.fail msg 76 + 77 + let test_native_kill () = 78 + Eio_main.run @@ fun env -> 79 + Eio.Switch.run @@ fun sw -> 80 + let runtime = Monitor.Process.create ~sw ~env () in 81 + let config = Monitor.Process_config.v "sleep" [ "100" ] in 82 + match Monitor.Process.start runtime config with 83 + | Ok handle -> 84 + Monitor.Process.kill runtime handle; 85 + let status = Monitor.Process.wait runtime handle in 86 + Alcotest.(check bool) "killed" true (status = Monitor.Signaled Sys.sigkill) 87 + | Error msg -> Alcotest.fail msg 88 + 89 + let suite = 90 + ( "monitor", 91 + [ 92 + Alcotest.test_case "status running" `Quick test_status_running; 93 + Alcotest.test_case "status exited" `Quick test_status_exited; 94 + Alcotest.test_case "status signaled" `Quick test_status_signaled; 95 + Alcotest.test_case "config basic" `Quick test_native_config_basic; 96 + Alcotest.test_case "config with env" `Quick test_native_config_with_env; 97 + Alcotest.test_case "config with cwd" `Quick test_native_config_with_cwd; 98 + Alcotest.test_case "create" `Quick test_native_create; 99 + Alcotest.test_case "start/wait" `Quick test_native_start_wait; 100 + Alcotest.test_case "kill" `Quick test_native_kill; 101 + ] )
+2
test/test_monitor.mli
··· 1 + val suite : string * unit Alcotest.test_case list 2 + (** Alcotest suite for monitor tests. *)