RPMsg inter-partition messaging
0
fork

Configure Feed

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

test: add missing test files for pds, publicsuffix, punycode, rpmsg (E605)

- ocaml-pds: test_blob_store (13 tests), test_sqlite_blockstore (14 tests)
- ocaml-publicsuffix: test_publicsuffix (21 tests, Mozilla PSL vectors),
test_publicsuffix_cmd (11 tests)
- ocaml-punycode: test_punycode_idna (51 tests, RFC 5891 IDNA vectors)
- ocaml-rpmsg: test_rpmsg (9 tests, Linux kernel rpmsg constants)

+39 -18
+39 -18
test/test_rpmsg.ml
··· 1 - (** Tests for Rpmsg.Endpoint module. 1 + (** Tests for the Rpmsg top-level module API. 2 2 3 - Tests message transport using Eio pipes (simulating /dev/rpmsgN). The 4 - ioctl-based Ctrl operations require Linux RPMsg devices and are not testable 5 - on macOS. 3 + Covers endpoint_info record construction, endpoint_info_size, Endpoint 4 + transport via Eio pipes, and Ctrl platform check. Wire codec roundtrips are 5 + tested separately in test_wire.ml. 6 6 7 7 Upstream test vectors from Linux kernel: 8 - - Max message size: 496 bytes (512 - 16 byte virtio header) 9 - - RPMsg endpoint info struct: name[32], src u32, dst u32 10 - - Device paths: /dev/rpmsg_ctrlN, /dev/rpmsgN *) 8 + - rpmsg_endpoint_info struct size: 40 bytes 9 + - RPMSG_CREATE_EPT_IOCTL: 0x4028b501 10 + - RPMSG_DESTROY_EPT_IOCTL: 0x4028b502 11 + - Max name length: 32 bytes (RPMSG_NAME_SIZE) 12 + - Max message size: 496 (RPMSG_BUF_SIZE=512 - sizeof(rpmsg_hdr)=16) *) 11 13 12 14 let with_eio f () = Eio_main.run @@ fun _env -> f () 13 15 ··· 17 19 let source, sink = Eio.Process.pipe ~sw (Eio.Stdenv.process_mgr env) in 18 20 f ~source ~sink 19 21 22 + (* -- endpoint_info record -- *) 23 + 24 + let test_endpoint_info_construction = 25 + with_eio @@ fun () -> 26 + let info = Rpmsg.{ name = "test-channel"; src = 1024; dst = 1025 } in 27 + Alcotest.(check string) "name" "test-channel" info.name; 28 + Alcotest.(check int) "src" 1024 info.src; 29 + Alcotest.(check int) "dst" 1025 info.dst 30 + 31 + let test_endpoint_info_size = 32 + with_eio @@ fun () -> 33 + (* name[32] + src(u32) + dst(u32) = 40 bytes *) 34 + Alcotest.(check int) "size" 40 Rpmsg.endpoint_info_size 35 + 20 36 (* -- constants -- *) 21 37 22 38 let test_max_message_size = ··· 33 49 34 50 let test_send_recv = 35 51 with_pipe @@ fun ~source ~sink -> 36 - let sender = Rpmsg.Endpoint.of_source_sink ~source ~sink in 52 + let ep = Rpmsg.Endpoint.of_source_sink ~source ~sink in 37 53 let msg = "hello rpmsg" in 38 - Rpmsg.Endpoint.send sender msg; 39 - match Rpmsg.Endpoint.recv sender ~max_size:256 with 54 + Rpmsg.Endpoint.send ep msg; 55 + match Rpmsg.Endpoint.recv ep ~max_size:256 with 40 56 | None -> Alcotest.fail "expected message" 41 57 | Some received -> Alcotest.(check string) "received" msg received 42 58 ··· 62 78 | Some received -> 63 79 Alcotest.(check int) 64 80 "recv max" Rpmsg.Endpoint.max_message_size (String.length received) 81 + 82 + (* -- endpoint close -- *) 83 + 84 + let test_endpoint_close = 85 + with_pipe @@ fun ~source ~sink -> 86 + let ep = Rpmsg.Endpoint.of_source_sink ~source ~sink in 87 + Rpmsg.Endpoint.close ep 65 88 66 89 (* -- ctrl platform check -- *) 67 90 ··· 77 100 78 101 let suite = 79 102 [ 80 - ( "constants", 103 + ( "rpmsg", 81 104 [ 105 + Alcotest.test_case "endpoint_info construction" `Quick 106 + test_endpoint_info_construction; 107 + Alcotest.test_case "endpoint_info_size" `Quick test_endpoint_info_size; 82 108 Alcotest.test_case "max_message_size" `Quick test_max_message_size; 83 109 Alcotest.test_case "virtio calculation" `Quick 84 110 test_max_message_size_virtio; 85 - ] ); 86 - ( "endpoint", 87 - [ 88 111 Alcotest.test_case "send/recv" `Quick test_send_recv; 89 112 Alcotest.test_case "binary" `Quick test_send_recv_binary; 90 113 Alcotest.test_case "max size" `Quick test_send_max_size; 91 - ] ); 92 - ( "ctrl", 93 - [ 94 - Alcotest.test_case "open fails on macOS" `Quick 114 + Alcotest.test_case "endpoint close" `Quick test_endpoint_close; 115 + Alcotest.test_case "ctrl open fails on macOS" `Quick 95 116 test_ctrl_open_fails_macos; 96 117 ] ); 97 118 ]