Skip to content

Commit

Permalink
test: add cases for the new connect_uri functions
Browse files Browse the repository at this point in the history
These use the `get_config` function to check the configuration is
as expected.

Signed-off-by: David Scott <[email protected]>
  • Loading branch information
djs55 committed Sep 19, 2016
1 parent 64b7b60 commit 55165d2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib_test/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,21 @@ let test_flush () =
) in
Lwt_main.run t

let test_connect_uri query buffered sync () =
let t =
with_temp_file
(fun file ->
let uri = Uri.of_string (Printf.sprintf "file://%s%s" file query) in
Block.connect_uri uri >>= function
| `Error _ -> failwith (Printf.sprintf "Block.connect %s failed" (Uri.to_string uri))
| `Ok device1 ->
let config = Block.get_config device1 in
assert_equal ~printer:string_of_bool buffered config.Block.buffered;
assert_equal ~printer:string_of_bool sync config.Block.sync;
Block.disconnect device1
) in
Lwt_main.run t

let not_implemented_on_windows = [
"test resize" >:: test_resize;
]
Expand All @@ -214,6 +229,9 @@ let tests = [
*)
"test read/write after last sector" >:: test_eof;
"test flush" >:: test_flush;
"test connect_uri" >:: (test_connect_uri "" false false);
"test connect_uri buffered=1" >:: (test_connect_uri "?buffered=1" true false);
"test connect_uri buffered=1&sync=1" >:: (test_connect_uri "?buffered=1&sync=1" true true);
"test write then read" >:: test_write_read;
"test that writes fail if the buffer has a bad length" >:: test_buffer_wrong_length;
] @ (if Sys.os_type <> "Win32" then not_implemented_on_windows else [])
Expand Down

0 comments on commit 55165d2

Please sign in to comment.