Make testSignal unittest not depend on default shell
authorIustin Pop <iustin@google.com>
Sat, 21 Jun 2008 08:14:04 +0000 (08:14 +0000)
committerIustin Pop <iustin@google.com>
Sat, 21 Jun 2008 08:14:04 +0000 (08:14 +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.

(This is a backport from trunk)

Reviewed-by: iustinp

From: Manuel Franceschini <manuel.franceschini@gmail.com>

test/ganeti.utils_unittest.py

index d57e0c0..990b9fa 100755 (executable)
@@ -166,8 +166,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):