--- a/testing/mozbase/mozprocess/tests/test_poll.py
+++ b/testing/mozbase/mozprocess/tests/test_poll.py
@@ -1,109 +1,128 @@
#!/usr/bin/env python
from __future__ import absolute_import
import os
import signal
+import mozinfo
import mozunit
from mozprocess import processhandler
import proctest
here = os.path.dirname(os.path.abspath(__file__))
class ProcTestPoll(proctest.ProcTest):
- """ Class to test process poll """
+ """Class to test process poll."""
def test_poll_before_run(self):
- """Process is not started, and poll() is called"""
-
+ """Process is not started, and poll() is called."""
p = processhandler.ProcessHandler([self.python, self.proclaunch,
"process_normal_finish.ini"],
cwd=here)
self.assertRaises(RuntimeError, p.poll)
def test_poll_while_running(self):
- """Process is started, and poll() is called"""
-
+ """Process is started, and poll() is called."""
p = processhandler.ProcessHandler([self.python, self.proclaunch,
"process_normal_finish.ini"],
cwd=here)
p.run()
returncode = p.poll()
self.assertEqual(returncode, None)
self.determine_status(p, True)
p.kill()
def test_poll_after_kill(self):
- """Process is killed, and poll() is called"""
-
+ """Process is killed, and poll() is called."""
p = processhandler.ProcessHandler([self.python, self.proclaunch,
"process_normal_finish.ini"],
cwd=here)
p.run()
returncode = p.kill()
- # We killed the process, so the returncode should be < 0
- self.assertLess(returncode, 0)
+ # We killed the process, so the returncode should be non-zero
+ if mozinfo.isWin:
+ self.assertGreater(returncode, 0,
+ 'Positive returncode expected, got "%s"' % returncode)
+ else:
+ self.assertLess(returncode, 0,
+ 'Negative returncode expected, got "%s"' % returncode)
+
self.assertEqual(returncode, p.poll())
self.determine_status(p)
def test_poll_after_kill_no_process_group(self):
- """Process (no group) is killed, and poll() is called"""
-
+ """Process (no group) is killed, and poll() is called."""
p = processhandler.ProcessHandler([self.python, self.proclaunch,
"process_normal_finish_no_process_group.ini"],
cwd=here,
ignore_children=True
)
p.run()
returncode = p.kill()
- # We killed the process, so the returncode should be < 0
- self.assertLess(returncode, 0)
+ # We killed the process, so the returncode should be non-zero
+ if mozinfo.isWin:
+ self.assertGreater(returncode, 0,
+ 'Positive returncode expected, got "%s"' % returncode)
+ else:
+ self.assertLess(returncode, 0,
+ 'Negative returncode expected, got "%s"' % returncode)
+
self.assertEqual(returncode, p.poll())
self.determine_status(p)
def test_poll_after_double_kill(self):
- """Process is killed twice, and poll() is called"""
-
+ """Process is killed twice, and poll() is called."""
p = processhandler.ProcessHandler([self.python, self.proclaunch,
"process_normal_finish.ini"],
cwd=here)
p.run()
p.kill()
returncode = p.kill()
- # We killed the process, so the returncode should be < 0
- self.assertLess(returncode, 0)
+ # We killed the process, so the returncode should be non-zero
+ if mozinfo.isWin:
+ self.assertGreater(returncode, 0,
+ 'Positive returncode expected, got "%s"' % returncode)
+ else:
+ self.assertLess(returncode, 0,
+ 'Negative returncode expected, got "%s"' % returncode)
+
self.assertEqual(returncode, p.poll())
self.determine_status(p)
def test_poll_after_external_kill(self):
- """Process is killed externally, and poll() is called"""
-
+ """Process is killed externally, and poll() is called."""
p = processhandler.ProcessHandler([self.python, self.proclaunch,
"process_normal_finish.ini"],
cwd=here)
p.run()
os.kill(p.pid, signal.SIGTERM)
returncode = p.wait()
- # We killed the process, so the returncode should be < 0
- self.assertEqual(returncode, -signal.SIGTERM)
+ # We killed the process, so the returncode should be non-zero
+ if mozinfo.isWin:
+ self.assertEqual(returncode, signal.SIGTERM,
+ 'Positive returncode expected, got "%s"' % returncode)
+ else:
+ self.assertEqual(returncode, -signal.SIGTERM,
+ '%s expected, got "%s"' % (-signal.SIGTERM, returncode))
+
self.assertEqual(returncode, p.poll())
self.determine_status(p)
if __name__ == '__main__':
mozunit.main()
--- a/testing/mozbase/mozprocess/tests/test_wait.py
+++ b/testing/mozbase/mozprocess/tests/test_wait.py
@@ -86,16 +86,21 @@ class ProcTestWait(proctest.ProcTest):
cwd=here)
p.run()
p.kill()
returncode1 = p.wait()
returncode2 = p.wait()
self.determine_status(p)
- self.assertLess(returncode2, 0,
- 'Negative returncode expected, got "%s"' % returncode2)
+ # We killed the process, so the returncode should be non-zero
+ if mozinfo.isWin:
+ self.assertGreater(returncode2, 0,
+ 'Positive returncode expected, got "%s"' % returncode2)
+ else:
+ self.assertLess(returncode2, 0,
+ 'Negative returncode expected, got "%s"' % returncode2)
self.assertEqual(returncode1, returncode2,
'Expected both returncodes of wait() to be equal')
if __name__ == '__main__':
mozunit.main()