Skip to content

Commit

Permalink
Merge pull request #5884 from edwintorok/private/edvint/ci-to-quicktest
Browse files Browse the repository at this point in the history
CP-50448: run quickcheck tests in XenRT
  • Loading branch information
edwintorok authored Jul 29, 2024
2 parents afe5fec + efcb7af commit 76b3db6
Show file tree
Hide file tree
Showing 18 changed files with 65 additions and 21 deletions.
16 changes: 10 additions & 6 deletions ocaml/libs/clock/dune
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
4 changes: 1 addition & 3 deletions ocaml/libs/clock/test_timer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
3 changes: 3 additions & 0 deletions ocaml/libs/clock/test_timer.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
val tests_span : unit Alcotest.V1.test_case list

val tests : QCheck2.Test.t list
4 changes: 4 additions & 0 deletions ocaml/libs/clock/test_timer_run.ml
Original file line number Diff line number Diff line change
@@ -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)]
Empty file.
4 changes: 3 additions & 1 deletion ocaml/libs/http-lib/bufio_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
()
1 change: 1 addition & 0 deletions ocaml/libs/http-lib/bufio_test.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
val tests : QCheck2.Test.t list
1 change: 1 addition & 0 deletions ocaml/libs/http-lib/bufio_test_run.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let () = QCheck_base_runner.run_tests_main Bufio_test.tests
Empty file.
19 changes: 14 additions & 5 deletions ocaml/libs/http-lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 9 additions & 3 deletions ocaml/libs/xapi-stdext/lib/xapi-stdext-unix/test/dune
Original file line number Diff line number Diff line change
@@ -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))
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
val tests : QCheck2.Test.t list
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let () = QCheck_base_runner.run_tests_main Unixext_test.tests
Empty file.
4 changes: 3 additions & 1 deletion ocaml/quicktest/dune
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@
(libraries
alcotest
astring

ezxenstore
ezxenstore.watch
fmt
forkexec
http_lib
mtime
mtime.clock.os
qcheck-alcotest
result
rresult
rpclib.core
rrdd_libs
stunnel
bufio_test
test_timer
threads.posix
unix
uuid
Expand Down
10 changes: 10 additions & 0 deletions ocaml/quicktest/quicktest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 () ->
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions ocaml/quicktest/quicktest_args.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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. *)
Expand All @@ -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)
Expand Down

0 comments on commit 76b3db6

Please sign in to comment.