1) prevents a bug by logging stdout/stderr if retcode still None:

```
in executeCmd
    if retcode < 0:
TypeError: unorderable types: NoneType() < int()
```
2) prevents a rarely test case bug of testExecuteTimeoutWithNastyChildren, because no stdout (Resource temporarily unavailable), possible no flush by IO of the killing process;
pull/1346/head
sebres 9 years ago committed by sebres
parent 6406f6f560
commit 935d79eaae

@ -159,7 +159,7 @@ class Utils():
# if was timeouted (killed/terminated) - to prevent waiting, set std handles to non-blocking mode. # if was timeouted (killed/terminated) - to prevent waiting, set std handles to non-blocking mode.
if popen.stdout: if popen.stdout:
try: try:
if retcode < 0: if retcode is None or retcode < 0:
Utils.setFBlockMode(popen.stdout, False) Utils.setFBlockMode(popen.stdout, False)
stdout = popen.stdout.read() stdout = popen.stdout.read()
except IOError as e: except IOError as e:
@ -169,7 +169,7 @@ class Utils():
popen.stdout.close() popen.stdout.close()
if popen.stderr: if popen.stderr:
try: try:
if retcode < 0: if retcode is None or retcode < 0:
Utils.setFBlockMode(popen.stderr, False) Utils.setFBlockMode(popen.stderr, False)
stderr = popen.stderr.read() stderr = popen.stderr.read()
except IOError as e: except IOError as e:

@ -247,7 +247,7 @@ class CommandActionTest(LogCaptureTestCase):
cpid = getnastypid() cpid = getnastypid()
# Verify that the process itself got killed # Verify that the process itself got killed
self.assertTrue(Utils.wait_for(lambda: not pid_exists(cpid), 3)) # process should have been killed self.assertTrue(Utils.wait_for(lambda: not pid_exists(cpid), 3)) # process should have been killed
self.assertLogged('my pid ') self.assertLogged('my pid ', 'Resource temporarily unavailable')
self.assertLogged('timed out') self.assertLogged('timed out')
self.assertLogged('killed with SIGTERM', self.assertLogged('killed with SIGTERM',
'killed with SIGKILL') 'killed with SIGKILL')
@ -261,7 +261,7 @@ class CommandActionTest(LogCaptureTestCase):
cpid = getnastypid() cpid = getnastypid()
# Verify that the process itself got killed # Verify that the process itself got killed
self.assertTrue(Utils.wait_for(lambda: not pid_exists(cpid), 3)) self.assertTrue(Utils.wait_for(lambda: not pid_exists(cpid), 3))
self.assertLogged('my pid ') self.assertLogged('my pid ', 'Resource temporarily unavailable')
self.assertLogged('timed out') self.assertLogged('timed out')
self.assertLogged('killed with SIGTERM', self.assertLogged('killed with SIGTERM',
'killed with SIGKILL') 'killed with SIGKILL')

Loading…
Cancel
Save