From d7ebcdba84dfa889fd9278bda5fc08f2349df525 Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Fri, 22 Nov 2024 14:26:30 +0000 Subject: [PATCH] Add a test for Unixext.Direct module Very simple test. Exercise modified code. Signed-off-by: Frediano Ziglio --- .../lib/xapi-stdext-unix/test/unixext_test.ml | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/ocaml/libs/xapi-stdext/lib/xapi-stdext-unix/test/unixext_test.ml b/ocaml/libs/xapi-stdext/lib/xapi-stdext-unix/test/unixext_test.ml index be848f7b8a4..83983999541 100644 --- a/ocaml/libs/xapi-stdext/lib/xapi-stdext-unix/test/unixext_test.ml +++ b/ocaml/libs/xapi-stdext/lib/xapi-stdext-unix/test/unixext_test.ml @@ -281,8 +281,26 @@ let test_select = in true +let test_direct = + let gen = Gen.unit in + Test.make ~count:1 ~name:__FUNCTION__ gen @@ fun _ -> + let fn = "test_file_direct" in + let buf = Bytes.make 10000 'x' in + Unixext.Direct.with_openfile fn [Unix.O_RDWR; Unix.O_CREAT] 0o600 (fun f -> + let res = Unixext.Direct.write f buf 0 4096 in + QCheck2.assume (res = 4096) + ) ; + Unix.unlink fn ; + true + let tests = - [test_select; test_proxy; test_time_limited_write; test_time_limited_read] + [ + test_select + ; test_proxy + ; test_time_limited_write + ; test_time_limited_read + ; test_direct + ] let () = (* avoid SIGPIPE *)