From 815bf6d533526d833e83ff4a946f9d6af331edf3 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Mon, 22 Nov 2010 21:42:52 +0100
Subject: [PATCH] Fix utils unittest TestRunCmd.testTimeoutKill
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Currently the test executes "/bin/sh -c 'trap "" TERM …" via the shell,
which means we have two shells involved (the parent one and the child
one, which does the trap). For some weird reason, this works for older
OSes: the first shell exec's the second one, whereas on squeeze it forks
and only then exec. This might be due to changes in Python or bash or
whatever.

In any case, the point is that this is a hacky way to call a shell, so
we change this to simply execute the desired shell directly, without any
intermediate shells (I don't understand why it was written as such
originally).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: RenΓ© Nussbaumer <rn@google.com>
---
 test/ganeti.utils_unittest.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/test/ganeti.utils_unittest.py b/test/ganeti.utils_unittest.py
index 7165498c3..ef11e8ed0 100755
--- a/test/ganeti.utils_unittest.py
+++ b/test/ganeti.utils_unittest.py
@@ -296,10 +296,9 @@ class TestRunCmd(testutils.GanetiTestCase):
     self.assertEqual(result.exit_code, 0)
 
   def testTimeoutKill(self):
-    cmd = "trap '' TERM; read < %s" % self.fifo_file
+    cmd = ["/bin/sh", "-c", "trap '' TERM; read < %s" % self.fifo_file]
     timeout = 0.2
-    strcmd = utils.ShellQuoteArgs(["/bin/sh", "-c", cmd])
-    out, err, status, ta = utils._RunCmdPipe(strcmd, {}, True, "/", False,
+    out, err, status, ta = utils._RunCmdPipe(cmd, {}, False, "/", False,
                                              timeout, _linger_timeout=0.2)
     self.assert_(status < 0)
     self.assertEqual(-status, signal.SIGKILL)
-- 
GitLab