Nir Soffer has uploaded a new change for review.
Change subject: tests: Add test for terminating a terminated process ......................................................................
tests: Add test for terminating a terminated process
In this case we should find that the process has terminated and waited, and do not invoke kill().
Change-Id: Ic0f06c28857664cc49beb938f33ac3c9d07ca3b6 Signed-off-by: Nir Soffer nsoffer@redhat.com --- M tests/utilsTests.py 1 file changed, 12 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/28/65328/1
diff --git a/tests/utilsTests.py b/tests/utilsTests.py index 27a84e7..8c7ae61 100644 --- a/tests/utilsTests.py +++ b/tests/utilsTests.py @@ -111,6 +111,18 @@ pass self.assertEqual(self.proc.returncode, -signal.SIGTERM)
+ def test_process_terminated(self): + self.proc.terminate() + self.proc.wait() + + def fail(): + raise RuntimeError("Attempt to kill a terminated process") + + self.proc.kill = fail + with utils.terminating(self.proc): + pass + self.assertEqual(self.proc.returncode, -signal.SIGTERM) + def test_kill_failure(self): class FakeKillError(Exception): pass