def test_waiting_for_exiting_process_finishes_without_sigkill(self) -> None: process = AutoReapingChildProcess( ["python3", "-c", "import time; time.sleep(1)"] ) wait_for_shutdown(process.pid, timeout=5) returncode = process.wait() self.assertEqual(returncode, 0, "Process should have exited cleanly")
def test_waiting_for_alive_process_kills_with_sigkill(self) -> None: process = AutoReapingChildProcess(["sleep", "30"]) wait_for_shutdown(process.pid, timeout=1) returncode = process.wait() self.assertEqual( returncode, -signal.SIGKILL, "Process should have exited with SIGKILL" )
def test_waiting_for_exited_process_finishes_immediately(self) -> None: process = AutoReapingChildProcess(["python3", "-c", "0"]) process.wait() stop_watch = StopWatch() with stop_watch.measure(): wait_for_shutdown(process.pid, timeout=5) self.assertLessEqual(stop_watch.elapsed, 3)
def test_killed_daemon_is_not_running(self) -> None: with self.spawn_fake_edenfs(self.temp_dir) as daemon_pid: os.kill(daemon_pid, signal.SIGKILL) wait_for_shutdown(pid=daemon_pid, timeout=5) status_process = self.spawn_status([]) status_process.expect_exact("edenfs not running") self.assert_process_fails(status_process, exit_code=1)
def test_waiting_for_alive_process_kills_with_sigkill(self) -> None: process = AutoReapingChildProcess( ["python3", "-c", "import time; time.sleep(30)"] ) wait_for_shutdown(process.pid, timeout=1) returncode = process.wait() self.assertEqual( returncode, -signal.SIGKILL if sys.platform != "win32" else 1, "Process should have exited with SIGKILL", )