diff --git a/Makefile b/Makefile index 98ea92ab9..1fb922e66 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,11 @@ -.PHONY: all clean install build reinstall uninstall distclean +.PHONY: all clean install build test reinstall uninstall distclean all: build NAME=xenops J=4 +ENABLE_TESTS=--enable-tests + clean: @rm -f setup.data setup.log setup.bin lib/version.ml @rm -rf _build @@ -22,7 +24,7 @@ setup.bin: setup.ml @rm -f setup.cmx setup.cmi setup.o setup.cmo setup.data: setup.bin - @./setup.bin -configure $(ENABLE_XEN) $(ENABLE_XENLIGHT) $(ENABLE_LIBVIRT) $(ENABLE_XENGUESTBIN) + @./setup.bin -configure $(ENABLE_TESTS) $(ENABLE_XEN) $(ENABLE_XENLIGHT) $(ENABLE_LIBVIRT) $(ENABLE_XENGUESTBIN) build: setup.data setup.bin version.ml @./setup.bin -build -j $(J) @@ -39,6 +41,9 @@ endif ln -s ./xenops_xc_main.native xenopsd-xc || true ./xenopsd-xc --help=groff > xenopsd-xc.1 +test: build + @./setup.bin -test + version.ml: VERSION echo "let version = \"$(shell cat VERSION)\"" > lib/version.ml diff --git a/_oasis b/_oasis index bcdb75f45..822ca3191 100644 --- a/_oasis +++ b/_oasis @@ -217,3 +217,14 @@ Executable xenopsd_xenlight_main profiling CSources: fsync_stubs.c, poll_stubs.c +Executable xenopsd_test + CompiledObject: best + Path: test + MainIs: xenopsd_test.ml + Install: false + BuildDepends: oUnit, xenopsd + +Test xenopsd_test + Run$: flag(tests) + Command: $xenopsd_test + WorkingDirectory: . diff --git a/_tags b/_tags index 22df0dad6..8bf747939 100644 --- a/_tags +++ b/_tags @@ -1,5 +1,5 @@ # OASIS_START -# DO NOT EDIT (digest: 75c8d08bbb53d180415f0183181b9cf1) +# DO NOT EDIT (digest: 109e0ec543651aed62733bb129a75555) # 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 @@ -496,6 +496,53 @@ true: annot, bin_annot "xl/poll_stubs.c": use_profiling "xl/poll_stubs.c": use_xenopsd : custom +# Executable xenopsd_test +: pkg_cohttp +: pkg_fd-send-recv +: pkg_forkexec +: pkg_oUnit +: pkg_oclock +: pkg_rpclib +: pkg_rpclib.syntax +: pkg_sexplib +: pkg_sexplib.syntax +: pkg_threads +: pkg_threads.posix +: pkg_uri +: pkg_uuidm +: pkg_uutf +: pkg_xcp +: pkg_xcp.storage +: pkg_xcp.xen +: pkg_xenstore +: pkg_xenstore.unix +: pkg_xenstore_transport +: pkg_xenstore_transport.unix +: pkg_xmlm +: use_xenopsd +: pkg_cohttp +: pkg_fd-send-recv +: pkg_forkexec +: pkg_oUnit +: pkg_oclock +: pkg_rpclib +: pkg_rpclib.syntax +: pkg_sexplib +: pkg_sexplib.syntax +: pkg_threads +: pkg_threads.posix +: pkg_uri +: pkg_uuidm +: pkg_uutf +: pkg_xcp +: pkg_xcp.storage +: pkg_xcp.xen +: pkg_xenstore +: pkg_xenstore.unix +: pkg_xenstore_transport +: pkg_xenstore_transport.unix +: pkg_xmlm +: use_xenopsd # OASIS_STOP : syntax_camlp4o, pkg_rpc.syntax : syntax_camlp4o, pkg_rpc.syntax diff --git a/myocamlbuild.ml b/myocamlbuild.ml index 4c83bd4d9..29c539dde 100644 --- a/myocamlbuild.ml +++ b/myocamlbuild.ml @@ -1,5 +1,5 @@ (* OASIS_START *) -(* DO NOT EDIT (digest: 28a98a80b057607577ddf2e46a295148) *) +(* DO NOT EDIT (digest: 2bdc97604dd4b22615e2baab247559f1) *) module OASISGettext = struct (* # 22 "src/oasis/OASISGettext.ml" *) @@ -1059,6 +1059,7 @@ let package_default = ("xl", ["lib"; "profiling"]); ("xc", ["lib"; "profiling"]); ("tools", ["profiling"]); + ("test", ["lib"]); ("simulator", ["lib"; "profiling"]); ("libvirt", ["lib"; "profiling"]); ("lib", ["profiling"]) @@ -1070,6 +1071,6 @@ let conf = {MyOCamlbuildFindlib.no_automatic_syntax = false} let dispatch_default = MyOCamlbuildBase.dispatch_default conf package_default;; -# 1074 "myocamlbuild.ml" +# 1075 "myocamlbuild.ml" (* OASIS_STOP *) Ocamlbuild_plugin.dispatch dispatch_default;; diff --git a/setup.ml b/setup.ml index f971f1f9e..357b84628 100644 --- a/setup.ml +++ b/setup.ml @@ -1,7 +1,7 @@ (* setup.ml generated for the first time by OASIS v0.3.0 *) (* OASIS_START *) -(* DO NOT EDIT (digest: a35c6712bc4eeadb8afbb52bb7533da3) *) +(* DO NOT EDIT (digest: f30e3dbe8cc56e267c0675b7d4d561da) *) (* Regenerated by OASIS v0.4.6 Visit http://oasis.forge.ocamlcore.org for more information and @@ -6672,21 +6672,199 @@ end # 6674 "setup.ml" +module CustomPlugin = struct +(* # 22 "src/plugins/custom/CustomPlugin.ml" *) + + + (** Generate custom configure/build/doc/test/install system + @author + *) + + + open BaseEnv + open OASISGettext + open OASISTypes + + + + + + type t = + { + cmd_main: command_line conditional; + cmd_clean: (command_line option) conditional; + cmd_distclean: (command_line option) conditional; + } + + + let run = BaseCustom.run + + + let main t _ extra_args = + let cmd, args = + var_choose + ~name:(s_ "main command") + t.cmd_main + in + run cmd args extra_args + + + let clean t pkg extra_args = + match var_choose t.cmd_clean with + | Some (cmd, args) -> + run cmd args extra_args + | _ -> + () + + + let distclean t pkg extra_args = + match var_choose t.cmd_distclean with + | Some (cmd, args) -> + run cmd args extra_args + | _ -> + () + + + module Build = + struct + let main t pkg extra_args = + main t pkg extra_args; + List.iter + (fun sct -> + let evs = + match sct with + | Library (cs, bs, lib) when var_choose bs.bs_build -> + begin + let evs, _ = + BaseBuilt.of_library + OASISHostPath.of_unix + (cs, bs, lib) + in + evs + end + | Executable (cs, bs, exec) when var_choose bs.bs_build -> + begin + let evs, _, _ = + BaseBuilt.of_executable + OASISHostPath.of_unix + (cs, bs, exec) + in + evs + end + | _ -> + [] + in + List.iter + (fun (bt, bnm, lst) -> BaseBuilt.register bt bnm lst) + evs) + pkg.sections + + let clean t pkg extra_args = + clean t pkg extra_args; + (* TODO: this seems to be pretty generic (at least wrt to ocamlbuild + * considering moving this to BaseSetup? + *) + List.iter + (function + | Library (cs, _, _) -> + BaseBuilt.unregister BaseBuilt.BLib cs.cs_name + | Executable (cs, _, _) -> + BaseBuilt.unregister BaseBuilt.BExec cs.cs_name; + BaseBuilt.unregister BaseBuilt.BExecLib cs.cs_name + | _ -> + ()) + pkg.sections + + let distclean t pkg extra_args = + distclean t pkg extra_args + end + + + module Test = + struct + let main t pkg (cs, test) extra_args = + try + main t pkg extra_args; + 0.0 + with Failure s -> + BaseMessage.warning + (f_ "Test '%s' fails: %s") + cs.cs_name + s; + 1.0 + + let clean t pkg (cs, test) extra_args = + clean t pkg extra_args + + let distclean t pkg (cs, test) extra_args = + distclean t pkg extra_args + end + + + module Doc = + struct + let main t pkg (cs, _) extra_args = + main t pkg extra_args; + BaseBuilt.register BaseBuilt.BDoc cs.cs_name [] + + let clean t pkg (cs, _) extra_args = + clean t pkg extra_args; + BaseBuilt.unregister BaseBuilt.BDoc cs.cs_name + + let distclean t pkg (cs, _) extra_args = + distclean t pkg extra_args + end + + +end + + +# 6822 "setup.ml" open OASISTypes;; let setup_t = { BaseSetup.configure = InternalConfigurePlugin.configure; build = OCamlbuildPlugin.build []; - test = []; + test = + [ + ("xenopsd_test", + CustomPlugin.Test.main + { + CustomPlugin.cmd_main = + [(OASISExpr.EBool true, ("$xenopsd_test", []))]; + cmd_clean = [(OASISExpr.EBool true, None)]; + cmd_distclean = [(OASISExpr.EBool true, None)] + }) + ]; doc = []; install = InternalInstallPlugin.install; uninstall = InternalInstallPlugin.uninstall; clean = [OCamlbuildPlugin.clean]; - clean_test = []; + clean_test = + [ + ("xenopsd_test", + CustomPlugin.Test.clean + { + CustomPlugin.cmd_main = + [(OASISExpr.EBool true, ("$xenopsd_test", []))]; + cmd_clean = [(OASISExpr.EBool true, None)]; + cmd_distclean = [(OASISExpr.EBool true, None)] + }) + ]; clean_doc = []; distclean = []; - distclean_test = []; + distclean_test = + [ + ("xenopsd_test", + CustomPlugin.Test.distclean + { + CustomPlugin.cmd_main = + [(OASISExpr.EBool true, ("$xenopsd_test", []))]; + cmd_clean = [(OASISExpr.EBool true, None)]; + cmd_distclean = [(OASISExpr.EBool true, None)] + }) + ]; distclean_doc = []; package = { @@ -7172,7 +7350,61 @@ let setup_t = bs_nativeopt = [(OASISExpr.EBool true, ["-warn-error"; "+a-3"])] }, - {exec_custom = true; exec_main_is = "xenops_xl_main.ml"}) + {exec_custom = true; exec_main_is = "xenops_xl_main.ml"}); + Executable + ({ + cs_name = "xenopsd_test"; + cs_data = PropList.Data.create (); + cs_plugin_data = [] + }, + { + bs_build = [(OASISExpr.EBool true, true)]; + bs_install = [(OASISExpr.EBool true, false)]; + bs_path = "test"; + bs_compiled_object = Best; + bs_build_depends = + [ + FindlibPackage ("oUnit", None); + InternalLibrary "xenopsd" + ]; + bs_build_tools = [ExternalTool "ocamlbuild"]; + bs_c_sources = []; + bs_data_files = []; + bs_ccopt = [(OASISExpr.EBool true, [])]; + bs_cclib = [(OASISExpr.EBool true, [])]; + bs_dlllib = [(OASISExpr.EBool true, [])]; + bs_dllpath = [(OASISExpr.EBool true, [])]; + bs_byteopt = [(OASISExpr.EBool true, [])]; + bs_nativeopt = [(OASISExpr.EBool true, [])] + }, + {exec_custom = false; exec_main_is = "xenopsd_test.ml"}); + Test + ({ + cs_name = "xenopsd_test"; + cs_data = PropList.Data.create (); + cs_plugin_data = [] + }, + { + test_type = (`Test, "custom", Some "0.4"); + test_command = + [(OASISExpr.EBool true, ("$xenopsd_test", []))]; + test_custom = + { + pre_command = [(OASISExpr.EBool true, None)]; + post_command = [(OASISExpr.EBool true, None)] + }; + test_working_directory = Some "."; + test_run = + [ + (OASISExpr.ENot (OASISExpr.EFlag "tests"), false); + (OASISExpr.EFlag "tests", false); + (OASISExpr.EAnd + (OASISExpr.EFlag "tests", + OASISExpr.EFlag "tests"), + true) + ]; + test_tools = [ExternalTool "ocamlbuild"] + }) ]; plugins = [(`Extra, "META", Some "0.2")]; disable_oasis_section = []; @@ -7181,8 +7413,7 @@ let setup_t = }; oasis_fn = Some "_oasis"; oasis_version = "0.4.6"; - oasis_digest = - Some "0\155\"O\170\029\131\031\024\144\024\186\191\135\132y"; + oasis_digest = Some "v\255V\222CV\215\129_J\141[\012\195\226\231"; oasis_exec = None; oasis_setup_args = []; setup_update = false @@ -7190,6 +7421,6 @@ let setup_t = let setup () = BaseSetup.setup setup_t;; -# 7194 "setup.ml" +# 7425 "setup.ml" (* OASIS_STOP *) let () = setup ();; diff --git a/test/xenopsd_test.ml b/test/xenopsd_test.ml new file mode 100644 index 000000000..8c01ebacc --- /dev/null +++ b/test/xenopsd_test.ml @@ -0,0 +1,9 @@ +open OUnit + +let base_suite = + "base_suite" >::: + [ + ] + +let () = + ounit2_of_ounit1 base_suite |> OUnit2.run_test_tt_main