Skip to content

Commit

Permalink
Add a test for Unixext.Direct module
Browse files Browse the repository at this point in the history
Very simple test.
Exercise modified code.

Signed-off-by: Frediano Ziglio <[email protected]>
  • Loading branch information
freddy77 committed Nov 22, 2024
1 parent 5e3f5cc commit b0df73a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion ocaml/libs/xapi-stdext/lib/xapi-stdext-unix/test/unixext_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 1000 in
QCheck2.assume (res == 1000)
) ;
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 *)
Expand Down

0 comments on commit b0df73a

Please sign in to comment.