RPMsg inter-partition messaging
0
fork

Configure Feed

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

fix(lint): resolve E320, E335, E405, E600, E610, E718

- E320: shorten long identifier names in irmin/test/test_pds_interop.ml
- E335: remove underscore prefix from used bindings (env)
- E405: add doc comment to test_pds_interop.mli
- E600: flatten suite to single pair (string * test_case list)
- E610: extract PDS interop helpers into irmin/lib/pds_interop.ml
- E718: consolidate fuzz modules (punycode, rate-limit, requests, rpmsg)

+90 -101
+6 -6
fuzz/dune
··· 1 1 (executable 2 - (name fuzz_rpmsg) 3 - (modules fuzz_rpmsg fuzz_common fuzz_wire fuzz_endpoint) 2 + (name fuzz) 3 + (modules fuzz fuzz_rpmsg) 4 4 (libraries rpmsg eio eio_main crowbar fmt wire)) 5 5 6 6 (executable ··· 12 12 (alias runtest) 13 13 (enabled_if 14 14 (<> %{profile} afl)) 15 - (deps fuzz_rpmsg.exe) 15 + (deps fuzz.exe) 16 16 (action 17 - (run %{exe:fuzz_rpmsg.exe}))) 17 + (run %{exe:fuzz.exe}))) 18 18 19 19 (rule 20 20 (alias fuzz) ··· 22 22 (= %{profile} afl)) 23 23 (deps 24 24 (source_tree corpus) 25 - fuzz_rpmsg.exe 25 + fuzz.exe 26 26 gen_corpus.exe) 27 27 (action 28 - (echo "AFL fuzzer built: %{exe:fuzz_rpmsg.exe}\n"))) 28 + (echo "AFL fuzzer built: %{exe:fuzz.exe}\n")))
+1
fuzz/fuzz.ml
··· 1 + let () = Crowbar.run "rpmsg" [ Fuzz_rpmsg.suite ]
-3
fuzz/fuzz_common.ml
··· 1 - (** Common utilities for RPMsg fuzz tests. *) 2 - 3 - let truncate s = String.sub s 0 (min (String.length s) 512)
-61
fuzz/fuzz_endpoint.ml
··· 1 - (** Fuzz tests for Rpmsg.Endpoint module. 2 - 3 - Tests message transport via Eio pipes (simulating /dev/rpmsgN). Ioctl-based 4 - Ctrl operations require Linux and are not fuzzed. *) 5 - 6 - open Crowbar 7 - 8 - (** Send/recv roundtrip via Eio pipe - arbitrary messages must round-trip. *) 9 - let test_pipe_roundtrip buf = 10 - let buf = Fuzz_common.truncate buf in 11 - if String.length buf = 0 then () 12 - else 13 - Eio_main.run @@ fun env -> 14 - Eio.Switch.run @@ fun sw -> 15 - let source, sink = Eio.Process.pipe ~sw (Eio.Stdenv.process_mgr env) in 16 - let ep = Rpmsg.Endpoint.of_source_sink ~source ~sink in 17 - Rpmsg.Endpoint.send ep buf; 18 - match Rpmsg.Endpoint.recv ep ~max_size:512 with 19 - | None -> fail "expected message" 20 - | Some received -> if received <> buf then fail "roundtrip mismatch" 21 - 22 - (** Max-size messages must round-trip. *) 23 - let test_max_size_message buf = 24 - let max = Rpmsg.Endpoint.max_message_size in 25 - let buf = String.sub buf 0 (min (String.length buf) max) in 26 - if String.length buf = 0 then () 27 - else 28 - Eio_main.run @@ fun env -> 29 - Eio.Switch.run @@ fun sw -> 30 - let source, sink = Eio.Process.pipe ~sw (Eio.Stdenv.process_mgr env) in 31 - let ep = Rpmsg.Endpoint.of_source_sink ~source ~sink in 32 - Rpmsg.Endpoint.send ep buf; 33 - match Rpmsg.Endpoint.recv ep ~max_size:max with 34 - | None -> fail "expected message" 35 - | Some received -> 36 - if received <> buf then fail "max size roundtrip mismatch" 37 - 38 - (** Binary payloads with null bytes must round-trip. *) 39 - let test_binary_payload b1 b2 b3 b4 = 40 - let buf = 41 - String.init 4 (fun i -> 42 - Char.chr ((match i with 0 -> b1 | 1 -> b2 | 2 -> b3 | _ -> b4) mod 256)) 43 - in 44 - Eio_main.run @@ fun env -> 45 - Eio.Switch.run @@ fun sw -> 46 - let source, sink = Eio.Process.pipe ~sw (Eio.Stdenv.process_mgr env) in 47 - let ep = Rpmsg.Endpoint.of_source_sink ~source ~sink in 48 - Rpmsg.Endpoint.send ep buf; 49 - match Rpmsg.Endpoint.recv ep ~max_size:4 with 50 - | None -> fail "expected message" 51 - | Some received -> if received <> buf then fail "binary roundtrip mismatch" 52 - 53 - let suite = 54 - ( "endpoint", 55 - [ 56 - test_case "pipe roundtrip" [ bytes ] test_pipe_roundtrip; 57 - test_case "max size message" [ bytes ] test_max_size_message; 58 - test_case "binary payload" 59 - [ uint8; uint8; uint8; uint8 ] 60 - test_binary_payload; 61 - ] )
+83 -2
fuzz/fuzz_rpmsg.ml
··· 1 - (** Main entry point for RPMsg fuzz tests. *) 1 + (** Fuzz tests for the rpmsg library (wire codec and endpoint transport). *) 2 + 3 + open Crowbar 4 + 5 + let truncate s = String.sub s 0 (min (String.length s) 512) 6 + 7 + (* ── Wire codec ────────────────────────────────────────────────────────── *) 8 + 9 + let test_codec_roundtrip name src dst = 10 + let info = Rpmsg.{ name; src; dst } in 11 + let buf = Bytes.create Rpmsg.endpoint_info_size in 12 + Wire.Codec.encode Rpmsg.endpoint_info_codec info buf 0; 13 + let decoded = Wire.Codec.decode Rpmsg.endpoint_info_codec buf 0 in 14 + if decoded.src <> src then fail "src mismatch"; 15 + if decoded.dst <> dst then fail "dst mismatch" 16 + 17 + let test_decode_crash_safety buf = 18 + if String.length buf < Rpmsg.endpoint_info_size then () 19 + else 20 + let b = Bytes.of_string buf in 21 + let _ = Wire.Codec.decode Rpmsg.endpoint_info_codec b 0 in 22 + () 23 + 24 + (* ── Endpoint transport ────────────────────────────────────────────────── *) 25 + 26 + let test_pipe_roundtrip buf = 27 + let buf = truncate buf in 28 + if String.length buf = 0 then () 29 + else 30 + Eio_main.run @@ fun env -> 31 + Eio.Switch.run @@ fun sw -> 32 + let source, sink = Eio.Process.pipe ~sw (Eio.Stdenv.process_mgr env) in 33 + let ep = Rpmsg.Endpoint.of_source_sink ~source ~sink in 34 + Rpmsg.Endpoint.send ep buf; 35 + match Rpmsg.Endpoint.recv ep ~max_size:512 with 36 + | None -> fail "expected message" 37 + | Some received -> if received <> buf then fail "roundtrip mismatch" 38 + 39 + let test_max_size_message buf = 40 + let max = Rpmsg.Endpoint.max_message_size in 41 + let buf = String.sub buf 0 (min (String.length buf) max) in 42 + if String.length buf = 0 then () 43 + else 44 + Eio_main.run @@ fun env -> 45 + Eio.Switch.run @@ fun sw -> 46 + let source, sink = Eio.Process.pipe ~sw (Eio.Stdenv.process_mgr env) in 47 + let ep = Rpmsg.Endpoint.of_source_sink ~source ~sink in 48 + Rpmsg.Endpoint.send ep buf; 49 + match Rpmsg.Endpoint.recv ep ~max_size:max with 50 + | None -> fail "expected message" 51 + | Some received -> 52 + if received <> buf then fail "max size roundtrip mismatch" 2 53 3 - let () = Crowbar.run "rpmsg" [ Fuzz_wire.suite; Fuzz_endpoint.suite ] 54 + let test_binary_payload b1 b2 b3 b4 = 55 + let buf = 56 + String.init 4 (fun i -> 57 + Char.chr ((match i with 0 -> b1 | 1 -> b2 | 2 -> b3 | _ -> b4) mod 256)) 58 + in 59 + Eio_main.run @@ fun env -> 60 + Eio.Switch.run @@ fun sw -> 61 + let source, sink = Eio.Process.pipe ~sw (Eio.Stdenv.process_mgr env) in 62 + let ep = Rpmsg.Endpoint.of_source_sink ~source ~sink in 63 + Rpmsg.Endpoint.send ep buf; 64 + match Rpmsg.Endpoint.recv ep ~max_size:4 with 65 + | None -> fail "expected message" 66 + | Some received -> if received <> buf then fail "binary roundtrip mismatch" 67 + 68 + (* ── Suite ─────────────────────────────────────────────────────────────── *) 69 + 70 + let suite = 71 + ( "rpmsg", 72 + [ 73 + (* Wire codec *) 74 + test_case "codec roundtrip" 75 + [ bytes; range 65536; range 65536 ] 76 + test_codec_roundtrip; 77 + test_case "decode crash safety" [ bytes ] test_decode_crash_safety; 78 + (* Endpoint transport *) 79 + test_case "pipe roundtrip" [ bytes ] test_pipe_roundtrip; 80 + test_case "max size message" [ bytes ] test_max_size_message; 81 + test_case "binary payload" 82 + [ uint8; uint8; uint8; uint8 ] 83 + test_binary_payload; 84 + ] )
-29
fuzz/fuzz_wire.ml
··· 1 - (** Fuzz tests for Rpmsg wire codec. *) 2 - 3 - open Crowbar 4 - 5 - (** Codec roundtrip - encode then decode must preserve values. *) 6 - let test_codec_roundtrip name src dst = 7 - let info = Rpmsg.{ name; src; dst } in 8 - let buf = Bytes.create Rpmsg.endpoint_info_size in 9 - Wire.Codec.encode Rpmsg.endpoint_info_codec info buf 0; 10 - let decoded = Wire.Codec.decode Rpmsg.endpoint_info_codec buf 0 in 11 - if decoded.src <> src then fail "src mismatch"; 12 - if decoded.dst <> dst then fail "dst mismatch" 13 - 14 - (** Decode arbitrary bytes - must not crash. *) 15 - let test_decode_crash_safety buf = 16 - if String.length buf < Rpmsg.endpoint_info_size then () 17 - else 18 - let b = Bytes.of_string buf in 19 - let _ = Wire.Codec.decode Rpmsg.endpoint_info_codec b 0 in 20 - () 21 - 22 - let suite = 23 - ( "wire", 24 - [ 25 - test_case "codec roundtrip" 26 - [ bytes; range 65536; range 65536 ] 27 - test_codec_roundtrip; 28 - test_case "decode crash safety" [ bytes ] test_decode_crash_safety; 29 - ] )