diff --git a/ocaml/libs/clock/dune b/ocaml/libs/clock/dune index ebc174c9f2e..67fbef3208f 100644 --- a/ocaml/libs/clock/dune +++ b/ocaml/libs/clock/dune @@ -11,19 +11,23 @@ ) ) -(tests - (names test_date test_timer) +(library + (name test_timer) (package clock) - (modules test_date test_timer) + (modules test_timer) (libraries alcotest clock fmt - mtime mtime.clock.os - ptime qcheck-alcotest qcheck-core - qcheck-core.runner ) ) + +(tests + (names test_date test_timer_run) + (package clock) + (modules test_date test_timer_run) + (libraries alcotest clock fmt mtime mtime.clock.os ptime qcheck-core qcheck-alcotest test_timer) +) diff --git a/ocaml/libs/clock/test_timer.ml b/ocaml/libs/clock/test_timer.ml index fca152ee96d..3729826cfa3 100644 --- a/ocaml/libs/clock/test_timer.ml +++ b/ocaml/libs/clock/test_timer.ml @@ -60,8 +60,6 @@ let test_timer_remaining = Mtime.Span.pp duration Timer.pp timer ; true -let tests_timer = List.map QCheck_alcotest.to_alcotest [test_timer_remaining] - let combinations = let pair x y = (x, y) in let rec loop acc = function @@ -154,4 +152,4 @@ let test_conversion_from_s = let tests_span = List.concat [test_conversion_to_s; test_conversion_from_s; test_span_compare] -let () = Alcotest.run "Timer" [("Timer", tests_timer); ("Span", tests_span)] +let tests = [test_timer_remaining] diff --git a/ocaml/libs/clock/test_timer.mli b/ocaml/libs/clock/test_timer.mli index e69de29bb2d..510dfaf2bdc 100644 --- a/ocaml/libs/clock/test_timer.mli +++ b/ocaml/libs/clock/test_timer.mli @@ -0,0 +1,3 @@ +val tests_span : unit Alcotest.V1.test_case list + +val tests : QCheck2.Test.t list diff --git a/ocaml/libs/clock/test_timer_run.ml b/ocaml/libs/clock/test_timer_run.ml new file mode 100644 index 00000000000..0bf62436fe6 --- /dev/null +++ b/ocaml/libs/clock/test_timer_run.ml @@ -0,0 +1,4 @@ +let tests_timer = List.map QCheck_alcotest.to_alcotest Test_timer.tests + +let () = + Alcotest.run "Timer" [("Timer", tests_timer); ("Span", Test_timer.tests_span)] diff --git a/ocaml/libs/clock/test_timer_run.mli b/ocaml/libs/clock/test_timer_run.mli new file mode 100644 index 00000000000..e69de29bb2d diff --git a/ocaml/libs/http-lib/bufio_test.ml b/ocaml/libs/http-lib/bufio_test.ml index 7937adc73ea..81aac2ad879 100644 --- a/ocaml/libs/http-lib/bufio_test.ml +++ b/ocaml/libs/http-lib/bufio_test.ml @@ -98,7 +98,9 @@ let test_buf_io = in true +let tests = [test_buf_io] + let () = (* avoid SIGPIPE *) let (_ : Sys.signal_behavior) = Sys.signal Sys.sigpipe Sys.Signal_ignore in - QCheck_base_runner.run_tests_main [test_buf_io] + () diff --git a/ocaml/libs/http-lib/bufio_test.mli b/ocaml/libs/http-lib/bufio_test.mli index e69de29bb2d..a10acd45016 100644 --- a/ocaml/libs/http-lib/bufio_test.mli +++ b/ocaml/libs/http-lib/bufio_test.mli @@ -0,0 +1 @@ +val tests : QCheck2.Test.t list diff --git a/ocaml/libs/http-lib/bufio_test_run.ml b/ocaml/libs/http-lib/bufio_test_run.ml new file mode 100644 index 00000000000..a7a1cacab7e --- /dev/null +++ b/ocaml/libs/http-lib/bufio_test_run.ml @@ -0,0 +1 @@ +let () = QCheck_base_runner.run_tests_main Bufio_test.tests diff --git a/ocaml/libs/http-lib/bufio_test_run.mli b/ocaml/libs/http-lib/bufio_test_run.mli new file mode 100644 index 00000000000..e69de29bb2d diff --git a/ocaml/libs/http-lib/dune b/ocaml/libs/http-lib/dune index 1deae570337..5cc1f8292e0 100644 --- a/ocaml/libs/http-lib/dune +++ b/ocaml/libs/http-lib/dune @@ -3,7 +3,7 @@ (public_name http-lib) (modes best) (wrapped false) - (modules (:standard \ http_svr http_proxy server_io http_test radix_tree_test test_client test_server bufio_test)) + (modules (:standard \ http_svr http_proxy server_io http_test radix_tree_test test_client test_server bufio_test bufio_test_run)) (preprocess (per_module ((pps ppx_deriving_rpc) Http))) (libraries astring @@ -67,9 +67,21 @@ ) (test - (name bufio_test) + (name bufio_test_run) (package http-lib) (modes (best exe)) + (modules bufio_test_run) + (libraries + qcheck-core.runner + bufio_test + ) + ; use fixed seed to avoid causing random failures in CI and package builds + (action (run %{test} -v -bt --seed 42)) +) + +(library + (name bufio_test) + (modes best) (modules bufio_test) (libraries fmt @@ -79,11 +91,8 @@ rresult http_lib qcheck-core - qcheck-core.runner xapi_fd_test ) - ; use fixed seed to avoid causing random failures in CI and package builds - (action (run %{test} -v -bt --seed 42)) ) (rule diff --git a/ocaml/libs/xapi-stdext/lib/xapi-stdext-unix/test/dune b/ocaml/libs/xapi-stdext/lib/xapi-stdext-unix/test/dune index 407d025a8a8..350db0ee85c 100644 --- a/ocaml/libs/xapi-stdext/lib/xapi-stdext-unix/test/dune +++ b/ocaml/libs/xapi-stdext/lib/xapi-stdext-unix/test/dune @@ -1,8 +1,14 @@ -(test +(library (name unixext_test) - (package xapi-stdext-unix) (modules unixext_test) - (libraries xapi_stdext_unix qcheck-core mtime.clock.os qcheck-core.runner fmt xapi_fd_test mtime threads.posix rresult) + (libraries xapi_stdext_unix qcheck-core mtime.clock.os fmt xapi_fd_test mtime threads.posix rresult) +) + +(test + (name unixext_test_run) + (package xapi-stdext-unix) + (modules unixext_test_run) + (libraries unixext_test qcheck-core.runner) ; use fixed seed to avoid causing random failures in CI and package builds (action (run %{test} -v -bt --seed 42)) ) 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 e0f2726f303..656dcc1fe56 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 @@ -192,5 +192,4 @@ let tests = [test_proxy; test_time_limited_write; test_time_limited_read] let () = (* avoid SIGPIPE *) let (_ : Sys.signal_behavior) = Sys.signal Sys.sigpipe Sys.Signal_ignore in - Xapi_stdext_unix.Unixext.test_open 1024 ; - QCheck_base_runner.run_tests_main tests + Xapi_stdext_unix.Unixext.test_open 1024 diff --git a/ocaml/libs/xapi-stdext/lib/xapi-stdext-unix/test/unixext_test.mli b/ocaml/libs/xapi-stdext/lib/xapi-stdext-unix/test/unixext_test.mli index e69de29bb2d..a10acd45016 100644 --- a/ocaml/libs/xapi-stdext/lib/xapi-stdext-unix/test/unixext_test.mli +++ b/ocaml/libs/xapi-stdext/lib/xapi-stdext-unix/test/unixext_test.mli @@ -0,0 +1 @@ +val tests : QCheck2.Test.t list diff --git a/ocaml/libs/xapi-stdext/lib/xapi-stdext-unix/test/unixext_test_run.ml b/ocaml/libs/xapi-stdext/lib/xapi-stdext-unix/test/unixext_test_run.ml new file mode 100644 index 00000000000..74c7a62241b --- /dev/null +++ b/ocaml/libs/xapi-stdext/lib/xapi-stdext-unix/test/unixext_test_run.ml @@ -0,0 +1 @@ +let () = QCheck_base_runner.run_tests_main Unixext_test.tests diff --git a/ocaml/libs/xapi-stdext/lib/xapi-stdext-unix/test/unixext_test_run.mli b/ocaml/libs/xapi-stdext/lib/xapi-stdext-unix/test/unixext_test_run.mli new file mode 100644 index 00000000000..e69de29bb2d diff --git a/ocaml/quicktest/dune b/ocaml/quicktest/dune index 31219a94d94..c4044a7ebb7 100644 --- a/ocaml/quicktest/dune +++ b/ocaml/quicktest/dune @@ -6,7 +6,6 @@ (libraries alcotest astring - ezxenstore ezxenstore.watch fmt @@ -14,11 +13,14 @@ http_lib mtime mtime.clock.os + qcheck-alcotest result rresult rpclib.core rrdd_libs stunnel + bufio_test + test_timer threads.posix unix uuid diff --git a/ocaml/quicktest/quicktest.ml b/ocaml/quicktest/quicktest.ml index e09f4a92fbb..09c7f89c7c9 100644 --- a/ocaml/quicktest/quicktest.ml +++ b/ocaml/quicktest/quicktest.ml @@ -14,6 +14,11 @@ (** The main entry point of the quicktest executable *) +let qchecks = + [("bufio", Bufio_test.tests); ("Timer", Test_timer.tests)] + |> List.map @@ fun (name, test) -> + (name, List.map QCheck_alcotest.(to_alcotest ~long:true) test) + let () = Quicktest_args.parse () ; Qt_filter.wrap (fun () -> @@ -43,6 +48,11 @@ let () = [("http", Quicktest_http.tests)] else [] + @ + if not !Quicktest_args.skip_stress then + qchecks + else + [] in (* Only list tests if asked, without running them *) if !Quicktest_args.list_tests then diff --git a/ocaml/quicktest/quicktest_args.ml b/ocaml/quicktest/quicktest_args.ml index d9659ba9105..cc05b27b667 100644 --- a/ocaml/quicktest/quicktest_args.ml +++ b/ocaml/quicktest/quicktest_args.ml @@ -45,6 +45,8 @@ let set_alcotest_args l = alcotest_args := Array.of_list l let skip_xapi = ref false +let skip_stress = ref false + (** Parse the legacy quicktest command line args. This is used instead of invoking Alcotest directly, for backwards-compatibility with clients who run the quicktest binary. *) @@ -67,6 +69,7 @@ let parse () = -default-sr" ) ; ("-skip-xapi", Arg.Set skip_xapi, "SKIP tests that require XAPI") + ; ("-skip-stress", Arg.Set skip_stress, "SKIP randomized stress tests") ; ("--", Arg.Rest_all set_alcotest_args, "Supply alcotest arguments") ; ( "-run-only" , Arg.String (fun x -> run_only := Some x)