Make testSignal unittest not depend on default shell
authorManuel Franceschini <manuel.franceschini@gmail.com>
Mon, 28 Apr 2008 10:42:04 +0000 (10:42 +0000)
committerManuel Franceschini <manuel.franceschini@gmail.com>
Mon, 28 Apr 2008 10:42:04 +0000 (10:42 +0000)
This patch changes the code executed when testing the signal handling
of RunCmd. Since sh does not always point to bash (e.g. on Ubuntu,
where it points to /bin/dash) this test might fail due to the returned
exit code is different so the received signal is not correctly
detected.

Additionally fix the docstring of testSignal.

Reviewed-by: iustinp

test/ganeti.utils_unittest.py

index b9035e7..abc4a76 100755 (executable)
@@ -155,8 +155,8 @@ class TestRunCmd(unittest.TestCase):
     self.assertEqual(result.output, "A" + self.magic + "B" + self.magic)
 
   def testSignal(self):
-    """Test standard error"""
-    result = RunCmd("/bin/sh -c 'kill -15 $$'")
+    """Test signal"""
+    result = RunCmd(["python", "-c", "import os; os.kill(os.getpid(), 15)"])
     self.assertEqual(result.signal, 15)
 
   def testListRun(self):