From e6921dad199f758a0c21f3596a0a48aa26a42896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= Date: Fri, 8 Apr 2022 13:39:55 +0100 Subject: [PATCH] xapi-guard/test: Count file descriptors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test is commented out because under certain conditions which couldn't be replicated at the end there are _less_ file descriptors that at the beginning. Signed-off-by: Edwin Török Signed-off-by: Pau Ruiz Safont --- ocaml/xapi-guard/test/xapi_guard_test.ml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ocaml/xapi-guard/test/xapi_guard_test.ml b/ocaml/xapi-guard/test/xapi_guard_test.ml index 2e3ec7a01c9..65d5f4a74d0 100644 --- a/ocaml/xapi-guard/test/xapi_guard_test.ml +++ b/ocaml/xapi-guard/test/xapi_guard_test.ml @@ -143,7 +143,18 @@ let bad_params_tests = ] ) -let test_shutdown _ () = Lwt_switch.turn_off Varstored_interface.shutdown +let linux_count_fds () = Sys.readdir "/proc/self/fd" |> Array.length + +let test_shutdown _ () = + let _fd0 = linux_count_fds () in + let noop ~rpc:_ ~session_id:_ () = Lwt.return_unit in + let* () = with_rpc noop Varstored_interface.shutdown () in + let* () = Lwt_switch.turn_off Varstored_interface.shutdown in + let _fd1 = linux_count_fds () in + (* Sometimes fd1 is lower than fd0, feel free to find the root cause and + uncomment the test! *) + (* Alcotest.(check' int) ~msg:"No FD leak" ~expected:_fd0 ~actual:_fd1 ; *) + Lwt.return_unit let shutdown_tests = ("Shutdown", [test_case "shutdown" `Quick test_shutdown])