Skip to content

Commit

Permalink
Merge 1dd3015 into 9654739
Browse files Browse the repository at this point in the history
  • Loading branch information
dsheets committed Nov 29, 2015
2 parents 9654739 + 1dd3015 commit 5a5c52a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -13,3 +13,4 @@ setup.bin
setup.data
setup.log
.coverage/
lib_test/_tests
4 changes: 2 additions & 2 deletions _oasis
Expand Up @@ -65,9 +65,9 @@ Executable test_client_lofs_server
Custom: true
CompiledObject: best
Install: false
BuildDepends: protocol-9p.unix, oUnit (>= 1.0.2)
BuildDepends: protocol-9p.unix, alcotest

Test test_client_lofs_server
Run$: flag(tests)
Command: $test_client_lofs_server -runner sequential
Command: $test_client_lofs_server
WorkingDirectory: lib_test
7 changes: 3 additions & 4 deletions _tags
@@ -1,5 +1,5 @@
# OASIS_START
# DO NOT EDIT (digest: 65771002b3bb51da9749cdc321321c1b)
# DO NOT EDIT (digest: 6f86e66c6146de830c85976ac7b97185)
# Ignore VCS directories, you can use the same kind of rule outside
# OASIS_START/STOP if you want to exclude directories that contains
# useless stuff for the build process
Expand Down Expand Up @@ -86,27 +86,26 @@ true: annot, bin_annot
<lib_test/tests.{native,byte}>: pkg_sexplib.syntax
<lib_test/tests.{native,byte}>: pkg_stringext
<lib_test/tests.{native,byte}>: use_protocol_9p
<lib_test/*.ml{,i,y}>: pkg_alcotest
<lib_test/tests.{native,byte}>: custom
# Executable test_client_lofs_server
<lib_test/lofs_test.{native,byte}>: pkg_alcotest
<lib_test/lofs_test.{native,byte}>: pkg_cstruct
<lib_test/lofs_test.{native,byte}>: pkg_cstruct.lwt
<lib_test/lofs_test.{native,byte}>: pkg_fmt
<lib_test/lofs_test.{native,byte}>: pkg_lwt
<lib_test/lofs_test.{native,byte}>: pkg_mirage-types.lwt
<lib_test/lofs_test.{native,byte}>: pkg_oUnit
<lib_test/lofs_test.{native,byte}>: pkg_result
<lib_test/lofs_test.{native,byte}>: pkg_sexplib
<lib_test/lofs_test.{native,byte}>: pkg_sexplib.syntax
<lib_test/lofs_test.{native,byte}>: pkg_stringext
<lib_test/lofs_test.{native,byte}>: use_protocol_9p
<lib_test/lofs_test.{native,byte}>: use_protocol_9p_unix
<lib_test/*.ml{,i,y}>: pkg_alcotest
<lib_test/*.ml{,i,y}>: pkg_cstruct
<lib_test/*.ml{,i,y}>: pkg_cstruct.lwt
<lib_test/*.ml{,i,y}>: pkg_fmt
<lib_test/*.ml{,i,y}>: pkg_lwt
<lib_test/*.ml{,i,y}>: pkg_mirage-types.lwt
<lib_test/*.ml{,i,y}>: pkg_oUnit
<lib_test/*.ml{,i,y}>: pkg_result
<lib_test/*.ml{,i,y}>: pkg_sexplib
<lib_test/*.ml{,i,y}>: pkg_sexplib.syntax
Expand Down
23 changes: 12 additions & 11 deletions lib_test/lofs_test.ml
Expand Up @@ -19,7 +19,6 @@ open Protocol_9p
open Lwt
open Infix
open Result
open OUnit

module LogServer = Log9p_unix.StdoutPrefix(struct let prefix = "S" end)
module LogClient1 = Log9p_unix.StdoutPrefix(struct let prefix = "C1" end)
Expand Down Expand Up @@ -76,7 +75,7 @@ let with_server f =
let with_client1 f =
Client1.connect ip port ()
>>= function
| Error (`Msg err) -> assert_failure ("client1: "^err)
| Error (`Msg err) -> Alcotest.fail ("client1: "^err)
| Ok client ->
Lwt.catch (fun () ->
f client
Expand All @@ -91,7 +90,7 @@ let with_client1 f =
let with_client2 f =
Client2.connect ip port ()
>>= function
| Error (`Msg err) -> assert_failure ("client2: "^err)
| Error (`Msg err) -> Alcotest.fail ("client2: "^err)
| Ok client ->
Lwt.catch (fun () ->
f client
Expand All @@ -117,23 +116,24 @@ let create_rebind_fid () =
(fun fid ->
Client1.walk_from_root _client1 fid []
>>= function
| Error (`Msg err) -> assert_failure ("client1: walk_from_root []: " ^ err)
| Error (`Msg err) ->
Alcotest.fail ("client1: walk_from_root []: " ^ err)
| Ok _ ->
let filemode = Types.FileMode.make ~owner:[`Write] () in
let openmode = Types.OpenMode.read_write in
(* create should rebind the fid to refer to the file foo... *)
Client1.LowLevel.create _client1 fid "foo" filemode openmode
>>= function
| Error (`Msg err) ->
assert_failure ("client1: create foo: " ^ err)
Alcotest.fail ("client1: create foo: " ^ err)
| Ok _ ->
let buf = Cstruct.create 16 in
Cstruct.memset buf 0;
(* ... so a write should succeed (but would fail on a directory) *)
Client1.LowLevel.write _client1 fid 0L buf
>>= function
| Error (`Msg err) ->
assert_failure ("client1: write: " ^ err)
Alcotest.fail ("client1: write: " ^ err)
| Ok _ ->
Lwt.return ()
)
Expand All @@ -144,15 +144,16 @@ let () = LogClient1.print_debug := false
let () = LogClient2.print_debug := false

let lwt_test name f =
name >:: (fun () -> Lwt_main.run (f ()))
name, `Quick, (fun () -> Lwt_main.run (f ()))

let tests = [
let test_client = [
lwt_test "connect1" (fun () -> with_server connect1);
lwt_test "connect2" (fun () -> with_server connect2);
lwt_test "check that create rebinds fids" (fun () -> with_server create_rebind_fid);
]

let () =
let suite = "client server" >::: tests in
let tests = [
"client", test_client;
]

OUnit2.run_test_tt_main (ounit2_of_ounit1 suite)
let () = Alcotest.run "client server" tests
31 changes: 8 additions & 23 deletions setup.ml
@@ -1,7 +1,7 @@
(* setup.ml generated for the first time by OASIS v0.4.5 *)

(* OASIS_START *)
(* DO NOT EDIT (digest: db7f167c55f401a8778c5fe5579ab2d4) *)
(* DO NOT EDIT (digest: abf64de13363cc646f7c7bdc597fc496) *)
(*
Regenerated by OASIS v0.4.5
Visit http://oasis.forge.ocamlcore.org for more information and
Expand Down Expand Up @@ -6817,11 +6817,7 @@ let setup_t =
CustomPlugin.Test.main
{
CustomPlugin.cmd_main =
[
(OASISExpr.EBool true,
("$test_client_lofs_server",
["-runner"; "sequential"]))
];
[(OASISExpr.EBool true, ("$test_client_lofs_server", []))];
cmd_clean = [(OASISExpr.EBool true, None)];
cmd_distclean = [(OASISExpr.EBool true, None)]
})
Expand Down Expand Up @@ -6849,11 +6845,7 @@ let setup_t =
CustomPlugin.Test.clean
{
CustomPlugin.cmd_main =
[
(OASISExpr.EBool true,
("$test_client_lofs_server",
["-runner"; "sequential"]))
];
[(OASISExpr.EBool true, ("$test_client_lofs_server", []))];
cmd_clean = [(OASISExpr.EBool true, None)];
cmd_distclean = [(OASISExpr.EBool true, None)]
})
Expand All @@ -6879,11 +6871,7 @@ let setup_t =
CustomPlugin.Test.distclean
{
CustomPlugin.cmd_main =
[
(OASISExpr.EBool true,
("$test_client_lofs_server",
["-runner"; "sequential"]))
];
[(OASISExpr.EBool true, ("$test_client_lofs_server", []))];
cmd_clean = [(OASISExpr.EBool true, None)];
cmd_distclean = [(OASISExpr.EBool true, None)]
})
Expand Down Expand Up @@ -7180,9 +7168,7 @@ let setup_t =
bs_build_depends =
[
InternalLibrary "protocol_9p_unix";
FindlibPackage
("oUnit",
Some (OASISVersion.VGreaterEqual "1.0.2"))
FindlibPackage ("alcotest", None)
];
bs_build_tools = [ExternalTool "ocamlbuild"];
bs_c_sources = [];
Expand All @@ -7206,8 +7192,7 @@ let setup_t =
test_command =
[
(OASISExpr.EBool true,
("$test_client_lofs_server",
["-runner"; "sequential"]))
("$test_client_lofs_server", []))
];
test_custom =
{
Expand Down Expand Up @@ -7235,14 +7220,14 @@ let setup_t =
};
oasis_fn = Some "_oasis";
oasis_version = "0.4.5";
oasis_digest = Some "Ò\003G+|¬-à»\006P<Éê?°";
oasis_digest = Some "\1382l½Pv\"ºH\017\144\006";
oasis_exec = None;
oasis_setup_args = [];
setup_update = false
};;

let setup () = BaseSetup.setup setup_t;;

# 7247 "setup.ml"
# 7232 "setup.ml"
(* OASIS_STOP *)
let () = setup ();;

0 comments on commit 5a5c52a

Please sign in to comment.