From 0b22fbb01be5c51cd2c055d235f596c4fa4df745 Mon Sep 17 00:00:00 2001 From: Fernando Gasperi Jabalera Date: Thu, 6 Feb 2020 03:10:10 -0800 Subject: [PATCH] Fix RestartSchedulerTests Summary: The RestartSchedulerTests were failing because they are run in parallel by OUnit and all share the same output directory. This makes the different tests collide since they are using the same file locks directory. Reviewed By: jvillard Differential Revision: D19765647 fbshipit-source-id: 5390ad14e --- infer/src/unit/RestartSchedulerTests.ml | 26 ++++++++----------------- infer/src/unit/inferunit.ml | 2 +- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/infer/src/unit/RestartSchedulerTests.ml b/infer/src/unit/RestartSchedulerTests.ml index b555ca1f1..35814afe4 100644 --- a/infer/src/unit/RestartSchedulerTests.ml +++ b/infer/src/unit/RestartSchedulerTests.ml @@ -10,33 +10,23 @@ open OUnit2 let a_pname = Procname.from_string_c_fun "a_c_fun_name" -let test_try_lock_already_locked _test_ctxt = +let tests_wrapper _test_ctxt = ProcLocker.( setup () ; + (* When tries to lock a Procname that was already locked it fails *) try_lock a_pname |> ignore ; assert_bool "Should not be able to lock a Procname that's already locked." - (not (try_lock a_pname))) - - -let test_lock_after_unlock _test_ctxt = - ProcLocker.( - setup () ; + (not (try_lock a_pname)) ; + unlock a_pname ; + (* When successives locks/unlocks are performed in the right order they succeed *) try_lock a_pname |> ignore ; unlock a_pname ; try_lock a_pname |> ignore ; - unlock a_pname) - - -let test_unlocking_unlocked_fails _text_ctxt = - ProcLocker.( - setup () ; + unlock a_pname ; + (* When an unlock is performed over a non-locked Procname it fails *) try_lock a_pname |> ignore ; unlock a_pname ; assert_raises (UnlockNotLocked a_pname) (fun () -> unlock a_pname)) -let tests = - "restart_scheduler_suite" - >::: [ "test_try_lock_already_locked" >:: test_try_lock_already_locked - ; "test_lock_after_unlock" >:: test_lock_after_unlock - ; "test_unlocking_unlocked_fails" >:: test_unlocking_unlocked_fails ] +let tests = "restart_scheduler_suite" >:: tests_wrapper diff --git a/infer/src/unit/inferunit.ml b/infer/src/unit/inferunit.ml index cb54d6b15..4b4dd7b29 100644 --- a/infer/src/unit/inferunit.ml +++ b/infer/src/unit/inferunit.ml @@ -40,13 +40,13 @@ let () = ; MaximumSharingTests.tests ; PerfProfilerATDParserTest.tests ; ProcCfgTests.tests + ; RestartSchedulerTests.tests ; SchedulerTests.tests ; SeverityTests.tests ; TaintTests.tests ; TraceTests.tests ; WeakTopologicalOrderTests.tests ] @ ClangTests.tests @ AllNullsafeTests.tests ) - @ [RestartSchedulerTests.tests] in let test_suite = "all" >::: tests in OUnit2.run_test_tt_main test_suite