diff --git a/Makefile b/Makefile index a1d5a628f33..810c812d9ec 100644 --- a/Makefile +++ b/Makefile @@ -21,11 +21,6 @@ build: check: dune build @check -j $(JOBS) -coverage: - dune runtest --instrument-with bisect_ppx --force --profile=$(RELEASE) -j $(JOBS) - bisect-ppx-report html - bisect-ppx-report summary --per-file - clean: dune clean diff --git a/dune-project b/dune-project index c5889ff42ac..65b34a4a9f2 100644 --- a/dune-project +++ b/dune-project @@ -858,7 +858,6 @@ (alcotest :with-test) astring base-unix - (bisect_ppx :with-test) (clock (and (= :version) diff --git a/ocaml/libs/xapi-stdext/lib/xapi-fd-test/dune b/ocaml/libs/xapi-stdext/lib/xapi-fd-test/dune index 07ce09f8745..3d5ef6fb5e6 100644 --- a/ocaml/libs/xapi-stdext/lib/xapi-fd-test/dune +++ b/ocaml/libs/xapi-stdext/lib/xapi-fd-test/dune @@ -2,7 +2,5 @@ (library (name xapi_fd_test) (libraries clock (re_export xapi-stdext-unix.fdcaps) unix qcheck-core logs fmt (re_export mtime) mtime.clock.os rresult threads.posix) - - ; off by default, enable with --instrument-with bisect_ppx (instrumentation (backend bisect_ppx)) ) diff --git a/ocaml/libs/xapi-stdext/lib/xapi-fdcaps/dune b/ocaml/libs/xapi-stdext/lib/xapi-fdcaps/dune index cd3754e6a21..ae5f8651b65 100644 --- a/ocaml/libs/xapi-stdext/lib/xapi-fdcaps/dune +++ b/ocaml/libs/xapi-stdext/lib/xapi-fdcaps/dune @@ -5,7 +5,5 @@ (name xapi_fdcaps) (libraries fmt unix threads.posix) (flags (:standard -principal)) - - ; off by default, enable with --instrument-with bisect_ppx (instrumentation (backend bisect_ppx)) ) diff --git a/ocaml/xapi-idl/lib/coverage/disabled.ml b/ocaml/xapi-idl/lib/coverage/disabled.ml deleted file mode 100644 index ca9ae41a07f..00000000000 --- a/ocaml/xapi-idl/lib/coverage/disabled.ml +++ /dev/null @@ -1,3 +0,0 @@ -let init _ = () - -let dispatcher_init _ = () diff --git a/ocaml/xapi-idl/lib/coverage/enabled.ml b/ocaml/xapi-idl/lib/coverage/enabled.ml deleted file mode 100644 index bf21ba07933..00000000000 --- a/ocaml/xapi-idl/lib/coverage/enabled.ml +++ /dev/null @@ -1,141 +0,0 @@ -(** This module sets up the env variable for bisect_ppx which describes where - log files are written. *) - -module D = Debug.Make (struct let name = "coverage" end) - -let prefix = "org.xen.xapi.coverage" - -module Bisect = struct - let bisect_file = "BISECT_FILE" - - let dump jobid = - let bisect_prefix = - match Sys.getenv_opt bisect_file with - | Some x -> - x - | None -> - D.warn "No $BISECT_FILE default set: %s" __LOC__ - in - (* dump coverage information in same location as it would normally get - dumped on exit, except also embed the jobid to make it easier to group. - Relies on [open_temp_file] generating a unique filename given a - prefix/suffix to avoid clashes with filenames created at exit by bisect - itself. *) - let tmp, ch = - Filename.open_temp_file - ~temp_dir:(Filename.dirname bisect_prefix) - (Filename.basename bisect_prefix) - (Printf.sprintf ".%Ld.out" jobid) - in - try - Bisect.Runtime.dump_counters_exn ch ; - D.debug "Saved coverage data to %s" tmp ; - close_out_noerr ch ; - (* Keep file - will be collected by XenRT *) - tmp - with e -> - Sys.remove tmp ; - D.warn "Failed to save coverage: %s" (Printexc.to_string e) ; - raise e - - let reset () = - Bisect.Runtime.reset_counters () ; - D.debug "Coverage counters reset" - - let init_env name = - let ( // ) = Filename.concat in - let tmpdir = Filename.get_temp_dir_name () in - if Option.is_none (Sys.getenv_opt bisect_file) then - Unix.putenv bisect_file (tmpdir // Printf.sprintf "bisect-%s-" name) - - let process body = - match Stringext.split ~on:' ' body with - | ["reset"] -> - reset () ; "" - | ["dump"; jobid] -> - jobid |> Int64.of_string |> dump - | _ -> - failwith body - - let init name = - init_env name ; - let queue_name = prefix ^ "." ^ name in - let (_ : Thread.t) = - Thread.create - (Message_switch_unix.Protocol_unix.Server.listen ~process - ~switch:!Xcp_client.switch_path ~queue:queue_name - ) - () - in - D.debug "Started coverage API thread on %s" queue_name ; - () -end - -module Dispatcher = struct - let self = prefix ^ ".dispatch" - - open Message_switch_unix.Protocol_unix - - let rpc_ignore_err ~t ~body queue = - D.debug "Dispatching %s to %s" body queue ; - match Client.(rpc ~t ~queue ~body () |> error_to_msg) with - | `Ok x -> - x - | `Error (`Msg e) -> - D.info "Failed to get coverage data from %s: %s" queue e ; - "" - - let string_of_result = function - | `Ok s -> - s - | `Error (`Msg e) -> - D.info "Failed to get coverage data: %s" e ; - "ERROR" - - let process body = - let open Message_switch_core.Mresult in - D.debug "Coverage dispatcher received %s" body ; - let result = - Client.connect ~switch:!Xcp_client.switch_path () - >>= (fun t -> - Client.list ~t ~prefix ~filter:`Alive () >>= fun queues -> - queues - |> (* filter out ourselves *) - List.filter (fun q -> self <> q) - |> (* best-effort: collect and return all non-failed results, log - errors *) - List.rev_map (rpc_ignore_err ~t ~body) - |> (* multiple return values converted to a single string, suitable - for use in a command like: mv $(message-cli call - org.xen.xapi.coverage.dispatch --timeout 60 --body 'dump - {jobid}') /tmp/coverage/ *) - String.concat " " - |> ok - ) - |> Client.error_to_msg - |> string_of_result - in - D.debug "Coverage dispatcher replying to '%s': %s" body result ; - result - - let init () = - (* receives command and dispatches to all other coverage message queues *) - let (_ : Thread.t) = - Thread.create - (Message_switch_unix.Protocol_unix.Server.listen ~process - ~switch:!Xcp_client.switch_path ~queue:self - ) - () - in - D.debug "Started coverage API dispatcher on %s" self ; - () -end - -(** [init name] sets up coverage profiling for binary [name]. You could use - [Sys.argv.(0)] for [name]. *) -let init name = - D.info "About to initialize coverage runtime" ; - Bisect.init name ; - D.info "Coverage runtime initialized" - -let dispatcher_init _name = Dispatcher.init () diff --git a/ocaml/xenopsd/COVERAGE.md b/ocaml/xenopsd/COVERAGE.md deleted file mode 100644 index 8f21d896fb4..00000000000 --- a/ocaml/xenopsd/COVERAGE.md +++ /dev/null @@ -1,46 +0,0 @@ -# Coverage Analysis - -This project can be compiled for coverage analysis using [bisect_ppx]. By -default, this is not done. To compile for coverage analysis, do: - - ./configure --enable-coverage - make - -This sets the `BISECT_ENABLE` make and environment variable, which adds a dependency -on `bisect_ppx` at `make setup.ml` time. -This ensures that a proper dependency gets added to the META file, so that other -projects can successfully link `xenopsd` even if they are themselves not built -with `bisect_ppx`. - -To get a non-coverage build simply run a default build: - - ./configure - make clean && make - -## Support Files - -See [profiling/coverage.ml](./profiling/coverage.ml) for the run-time -setup of coverage profiling. This code has no effect when not profiling -during execution. Once [bixect_ppx] has better defaults we could get rid -of it. - -## Execution and Logging - -During program execution, a binary writes coverage data to - - /tmp/bisect--*.out - -This can be overridden by setting the `BISECT_FILE` environment -variable, which is otherwise set at startup using the code in -`profiling/coverage.ml`; - -## Analysis - -See the [bisect_ppx] documentation for details but try from the -top-level directory: - - bisect-ppx-report -I _build -html coverage /tmp/bisect-*.out - -This creates an HTML document in [coverage/](./coverage]. - -[bisect_ppx]: https://github.com/aantron/bisect_ppx diff --git a/opam/xapi-stdext-unix.opam b/opam/xapi-stdext-unix.opam index 5e9d467f981..63c36e4af94 100644 --- a/opam/xapi-stdext-unix.opam +++ b/opam/xapi-stdext-unix.opam @@ -12,7 +12,6 @@ depends: [ "alcotest" {with-test} "astring" "base-unix" - "bisect_ppx" {with-test} "clock" {= version & with-test} "fd-send-recv" {>= "2.0.0"} "fmt" diff --git a/quality-gate.sh b/quality-gate.sh index c7965c34f0e..ff9142b6171 100755 --- a/quality-gate.sh +++ b/quality-gate.sh @@ -25,7 +25,7 @@ verify-cert () { } mli-files () { - N=459 + N=457 X="ocaml/tests" X+="|ocaml/quicktest" X+="|ocaml/message-switch/core_test"