Bug 1215756 - Fix mozprocess unit tests failures. r=ahal
authorJulien Pagès <j.parkouss@gmail.com>
Wed, 21 Oct 2015 10:57:58 -0400
changeset 304074 72bf30ffd77166d0813caf50218e0f31bedbe219
parent 304073 f81fb04f11896ac09c485a3f5fbbf5c0aee9cfce
child 304075 8a2cff15b0559d695c025ad1c61e73a040fcd7b8
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1215756
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1215756 - Fix mozprocess unit tests failures. r=ahal This now check process status based on pids, not anymore on an arbitrary string given in the command line. Some cleanup in there, including removing code duplicate.
testing/mozbase/mozprocess/tests/proctest.py
testing/mozbase/mozprocess/tests/test_mozprocess.py
testing/mozbase/mozprocess/tests/test_mozprocess_kill.py
testing/mozbase/mozprocess/tests/test_mozprocess_kill_broad_wait.py
testing/mozbase/mozprocess/tests/test_mozprocess_misc.py
testing/mozbase/mozprocess/tests/test_mozprocess_output.py
testing/mozbase/mozprocess/tests/test_mozprocess_poll.py
testing/mozbase/mozprocess/tests/test_mozprocess_wait.py
--- a/testing/mozbase/mozprocess/tests/proctest.py
+++ b/testing/mozbase/mozprocess/tests/proctest.py
@@ -1,58 +1,41 @@
 import os
 import sys
 import unittest
 import psutil
 
 here = os.path.dirname(os.path.abspath(__file__))
 
 
-def check_for_process(processName):
-    """
-        Use to determine if process of the given name is still running.
-
-        Returns:
-        detected -- True if process is detected to exist, False otherwise
-        output -- if process exists, stdout of the process, [] otherwise
-    """
-    name = os.path.basename(processName)
-    process = [p.pid for p in psutil.process_iter()
-               if p.name() == name]
-
-    if process:
-        return True, process
-    return False, []
-
-
 class ProcTest(unittest.TestCase):
 
     @classmethod
     def setUpClass(cls):
         cls.proclaunch = os.path.join(here, "proclaunch.py")
         cls.python = sys.executable
 
-    def determine_status(self,
-                         detected=False,
-                         output='',
-                         returncode=0,
-                         didtimeout=False,
-                         isalive=False,
-                         expectedfail=()):
+    def determine_status(self, proc, isalive=False, expectedfail=()):
         """
         Use to determine if the situation has failed.
         Parameters:
-            detected -- value from check_for_process to determine if the process is detected
-            output -- string of data from detected process, can be ''
-            returncode -- return code from process, defaults to 0
-            didtimeout -- True if process timed out, defaults to False
+            proc -- the processhandler instance
             isalive -- Use True to indicate we pass if the process exists; however, by default
                        the test will pass if the process does not exist (isalive == False)
             expectedfail -- Defaults to [], used to indicate a list of fields that are expected to fail
         """
+        returncode = proc.proc.returncode
+        didtimeout = proc.didTimeout
+        detected = psutil.pid_exists(proc.pid)
+        output = ''
+        # ProcessHandler has output when store_output is set to True in the constructor
+        # (this is the default)
+        if getattr(proc, 'output'):
+            output = proc.output
+
         if 'returncode' in expectedfail:
             self.assertTrue(returncode, "Detected an unexpected return code of: %s" % returncode)
         elif isalive:
             self.assertEqual(returncode, None, "Detected not None return code of: %s" % returncode)
         else:
             self.assertNotEqual(returncode, None, "Detected unexpected None return code of")
 
         if 'didtimeout' in expectedfail:
--- a/testing/mozbase/mozprocess/tests/test_mozprocess.py
+++ b/testing/mozbase/mozprocess/tests/test_mozprocess.py
@@ -3,16 +3,17 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import os
 import subprocess
 import sys
 import unittest
+import proctest
 from mozprocess import processhandler
 
 here = os.path.dirname(os.path.abspath(__file__))
 
 def make_proclaunch(aDir):
     """
         Makes the proclaunch executable.
         Params:
@@ -44,55 +45,18 @@ def make_proclaunch(aDir):
             print "stderr:\n%s" % stderr
             raise subprocess.CalledProcessError(process.returncode, command, stdout)
 
     # ensure the launcher now exists
     if not os.path.exists(exepath):
         raise AssertionError("proclaunch executable '%s' does not exist (sys.platform=%s)" % (exepath, sys.platform))
     return exepath
 
-def check_for_process(processName):
-    """
-        Use to determine if process of the given name is still running.
 
-        Returns:
-        detected -- True if process is detected to exist, False otherwise
-        output -- if process exists, stdout of the process, '' otherwise
-    """
-    # TODO: replace with
-    # https://github.com/mozilla/mozbase/blob/master/mozprocess/mozprocess/pid.py
-    # which should be augmented from talos
-    # see https://bugzilla.mozilla.org/show_bug.cgi?id=705864
-    output = ''
-    if sys.platform == "win32":
-        # On windows we use tasklist
-        p1 = subprocess.Popen(["tasklist"], stdout=subprocess.PIPE)
-        output = p1.communicate()[0]
-        detected = False
-        for line in output.splitlines():
-            if processName in line:
-                detected = True
-                break
-    else:
-        p1 = subprocess.Popen(["ps", "-ef"], stdout=subprocess.PIPE)
-        p2 = subprocess.Popen(["grep", processName], stdin=p1.stdout, stdout=subprocess.PIPE)
-        p1.stdout.close()
-        output = p2.communicate()[0]
-        detected = False
-        for line in output.splitlines():
-            if "grep %s" % processName in line:
-                continue
-            elif processName in line and not 'defunct' in line:
-                detected = True
-                break
-
-    return detected, output
-
-
-class ProcTest(unittest.TestCase):
+class ProcTest(proctest.ProcTest):
 
     # whether to remove created files on exit
     cleanup = os.environ.get('CLEANUP', 'true').lower() in ('1', 'true')
 
     @classmethod
     def setUpClass(cls):
         cls.proclaunch = make_proclaunch(here)
 
@@ -123,21 +87,17 @@ class ProcTest(unittest.TestCase):
     def test_process_normal_finish(self):
         """Process is started, runs to completion while we wait for it"""
 
         p = processhandler.ProcessHandler([self.proclaunch, "process_normal_finish.ini"],
                                           cwd=here)
         p.run()
         p.wait()
 
-        detected, output = check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              p.proc.returncode,
-                              p.didTimeout)
+        self.determine_status(p)
 
     def test_commandline_no_args(self):
         """Command line is reported correctly when no arguments are specified"""
         p = processhandler.ProcessHandler(self.proclaunch, cwd=here)
         self.assertEqual(p.commandline, self.proclaunch)
 
     def test_commandline_overspecified(self):
         """Command line raises an exception when the arguments are specified ambiguously"""
@@ -180,38 +140,28 @@ class ProcTest(unittest.TestCase):
         """Process is started runs to completion while we wait indefinitely"""
 
         p = processhandler.ProcessHandler([self.proclaunch,
                                           "process_waittimeout_10s.ini"],
                                           cwd=here)
         p.run()
         p.wait()
 
-        detected, output = check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              p.proc.returncode,
-                              p.didTimeout)
+        self.determine_status(p)
 
     def test_process_timeout(self):
         """ Process is started, runs but we time out waiting on it
             to complete
         """
         p = processhandler.ProcessHandler([self.proclaunch, "process_waittimeout.ini"],
                                           cwd=here)
         p.run(timeout=10)
         p.wait()
 
-        detected, output = check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              p.proc.returncode,
-                              p.didTimeout,
-                              False,
-                              ['returncode', 'didtimeout'])
+        self.determine_status(p, False, ['returncode', 'didtimeout'])
 
     def test_process_timeout_no_kill(self):
         """ Process is started, runs but we time out waiting on it
             to complete. Process should not be killed.
         """
         p = None
         def timeout_handler():
             self.assertEqual(p.proc.poll(), None)
@@ -219,120 +169,62 @@ class ProcTest(unittest.TestCase):
         p = processhandler.ProcessHandler([self.proclaunch, "process_waittimeout.ini"],
                                           cwd=here,
                                           onTimeout=(timeout_handler,),
                                           kill_on_timeout=False)
         p.run(timeout=1)
         p.wait()
         self.assertTrue(p.didTimeout)
 
-        detected, output = check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              p.proc.returncode,
-                              p.didTimeout,
-                              False,
-                              ['returncode', 'didtimeout'])
+        self.determine_status(p, False, ['returncode', 'didtimeout'])
 
     def test_process_waittimeout(self):
         """
         Process is started, then wait is called and times out.
         Process is still running and didn't timeout
         """
         p = processhandler.ProcessHandler([self.proclaunch,
                                           "process_waittimeout_10s.ini"],
                                           cwd=here)
 
         p.run()
         p.wait(timeout=5)
 
-        detected, output = check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              p.proc.returncode,
-                              p.didTimeout,
-                              True,
-                              ())
+        self.determine_status(p, True, ())
 
     def test_process_waitnotimeout(self):
         """ Process is started, runs to completion before our wait times out
         """
         p = processhandler.ProcessHandler([self.proclaunch,
                                           "process_waittimeout_10s.ini"],
                                           cwd=here)
         p.run(timeout=30)
         p.wait()
 
-        detected, output = check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              p.proc.returncode,
-                              p.didTimeout)
+        self.determine_status(p)
 
     def test_process_kill(self):
         """Process is started, we kill it"""
 
         p = processhandler.ProcessHandler([self.proclaunch, "process_normal_finish.ini"],
                                           cwd=here)
         p.run()
         p.kill()
 
-        detected, output = check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              p.proc.returncode,
-                              p.didTimeout)
+        self.determine_status(p)
 
     def test_process_output_twice(self):
         """
         Process is started, then processOutput is called a second time explicitly
         """
         p = processhandler.ProcessHandler([self.proclaunch,
                                           "process_waittimeout_10s.ini"],
                                           cwd=here)
 
         p.run()
         p.processOutput(timeout=5)
         p.wait()
 
-        detected, output = check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              p.proc.returncode,
-                              p.didTimeout,
-                              False,
-                              ())
+        self.determine_status(p, False, ())
 
-    def determine_status(self,
-                         detected=False,
-                         output='',
-                         returncode=0,
-                         didtimeout=False,
-                         isalive=False,
-                         expectedfail=()):
-        """
-        Use to determine if the situation has failed.
-        Parameters:
-            detected -- value from check_for_process to determine if the process is detected
-            output -- string of data from detected process, can be ''
-            returncode -- return code from process, defaults to 0
-            didtimeout -- True if process timed out, defaults to False
-            isalive -- Use True to indicate we pass if the process exists; however, by default
-                       the test will pass if the process does not exist (isalive == False)
-            expectedfail -- Defaults to [], used to indicate a list of fields that are expected to fail
-        """
-        if 'returncode' in expectedfail:
-            self.assertTrue(returncode, "Detected an unexpected return code of: %s" % returncode)
-        elif not isalive:
-            self.assertTrue(returncode == 0, "Detected non-zero return code of: %d" % returncode)
-
-        if 'didtimeout' in expectedfail:
-            self.assertTrue(didtimeout, "Detected that process didn't time out")
-        else:
-            self.assertTrue(not didtimeout, "Detected that process timed out")
-
-        if isalive:
-            self.assertTrue(detected, "Detected process is not running, process output: %s" % output)
-        else:
-            self.assertTrue(not detected, "Detected process is still running, process output: %s" % output)
 
 if __name__ == '__main__':
     unittest.main()
--- a/testing/mozbase/mozprocess/tests/test_mozprocess_kill.py
+++ b/testing/mozbase/mozprocess/tests/test_mozprocess_kill.py
@@ -21,70 +21,50 @@ class ProcTestKill(proctest.ProcTest):
     def test_process_kill(self):
         """Process is started, we kill it"""
 
         p = processhandler.ProcessHandler([self.python, self.proclaunch, "process_normal_finish_python.ini"],
                                           cwd=here)
         p.run()
         p.kill()
 
-        detected, output = proctest.check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              p.proc.returncode,
-                              p.didTimeout,
-                              expectedfail=('returncode',))
+        self.determine_status(p, expectedfail=('returncode',))
 
     def test_process_kill_deep(self):
         """Process is started, we kill it, we use a deep process tree"""
 
         p = processhandler.ProcessHandler([self.python, self.proclaunch, "process_normal_deep_python.ini"],
                                           cwd=here)
         p.run()
         p.kill()
 
-        detected, output = proctest.check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              p.proc.returncode,
-                              p.didTimeout,
-                              expectedfail=('returncode',))
+        self.determine_status(p, expectedfail=('returncode',))
 
     def test_process_kill_deep_wait(self):
         """Process is started, we use a deep process tree, we let it spawn
            for a bit, we kill it"""
 
         p = processhandler.ProcessHandler([self.python, self.proclaunch, "process_normal_deep_python.ini"],
                                           cwd=here)
         p.run()
         # Let the tree spawn a bit, before attempting to kill
         time.sleep(3)
         p.kill()
 
-        detected, output = proctest.check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              p.proc.returncode,
-                              p.didTimeout,
-                              expectedfail=('returncode',))
+        self.determine_status(p, expectedfail=('returncode',))
 
     def test_process_kill_broad(self):
         """Process is started, we kill it, we use a broad process tree"""
 
         p = processhandler.ProcessHandler([self.python, self.proclaunch, "process_normal_broad_python.ini"],
                                           cwd=here)
         p.run()
         p.kill()
 
-        detected, output = proctest.check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              p.proc.returncode,
-                              p.didTimeout,
-                              expectedfail=('returncode',))
+        self.determine_status(p, expectedfail=('returncode',))
 
     @unittest.skipUnless(processhandler.isPosix, "posix only")
     def test_process_kill_with_sigterm(self):
         script = os.path.join(here, 'infinite_loop.py')
         p = processhandler.ProcessHandler([self.python, script])
 
         p.run()
         p.kill()
--- a/testing/mozbase/mozprocess/tests/test_mozprocess_kill_broad_wait.py
+++ b/testing/mozbase/mozprocess/tests/test_mozprocess_kill_broad_wait.py
@@ -20,17 +20,12 @@ class ProcTestKill(proctest.ProcTest):
 
         p = processhandler.ProcessHandler([self.python, self.proclaunch, "process_normal_broad_python.ini"],
                                           cwd=here)
         p.run()
         # Let the tree spawn a bit, before attempting to kill
         time.sleep(3)
         p.kill()
 
-        detected, output = proctest.check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              p.proc.returncode,
-                              p.didTimeout,
-                              expectedfail=('returncode',))
+        self.determine_status(p, expectedfail=('returncode',))
 
 if __name__ == '__main__':
     unittest.main()
--- a/testing/mozbase/mozprocess/tests/test_mozprocess_misc.py
+++ b/testing/mozbase/mozprocess/tests/test_mozprocess_misc.py
@@ -17,18 +17,12 @@ class ProcTestMisc(proctest.ProcTest):
         p = processhandler.ProcessHandler([self.python, self.proclaunch,
                                           "process_waittimeout_10s_python.ini"],
                                           cwd=here)
 
         p.run()
         p.processOutput(timeout=5)
         p.wait()
 
-        detected, output = proctest.check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              p.proc.returncode,
-                              p.didTimeout,
-                              False,
-                              ())
+        self.determine_status(p, False, ())
 
 if __name__ == '__main__':
     unittest.main()
--- a/testing/mozbase/mozprocess/tests/test_mozprocess_output.py
+++ b/testing/mozbase/mozprocess/tests/test_mozprocess_output.py
@@ -17,23 +17,17 @@ class ProcTestOutput(proctest.ProcTest):
         """
         p = processhandler.ProcessHandler([self.python, "procnonewline.py"],
                                           cwd=here)
 
         p.run()
         p.processOutput(timeout=5)
         p.wait()
 
-        detected, output = proctest.check_for_process("procnonewline.py")
-        self.determine_status(detected,
-                              output,
-                              p.proc.returncode,
-                              p.didTimeout,
-                              False,
-                              ())
+        self.determine_status(p, False, ())
 
     def test_stream_process_output(self):
         """
         Process output stream does not buffer
         """
         expected = '\n'.join([str(n) for n in range(0,10)])
 
         stream = io.BytesIO()
@@ -51,18 +45,12 @@ class ProcTestOutput(proctest.ProcTest):
         buf.flush()
         self.assertEquals(stream.getvalue().strip(), expected)
 
         # make sure mozprocess doesn't close the stream
         # since mozprocess didn't create it
         self.assertFalse(buf.closed)
         buf.close()
 
-        detected, output = proctest.check_for_process("proccountfive.py")
-        self.determine_status(detected,
-                              output,
-                              p.proc.returncode,
-                              p.didTimeout,
-                              False,
-                              ())
+        self.determine_status(p, False, ())
 
 if __name__ == '__main__':
     unittest.main()
--- a/testing/mozbase/mozprocess/tests/test_mozprocess_poll.py
+++ b/testing/mozbase/mozprocess/tests/test_mozprocess_poll.py
@@ -29,99 +29,78 @@ class ProcTestPoll(proctest.ProcTest):
         p = processhandler.ProcessHandler([self.python, self.proclaunch,
                                           "process_normal_finish_python.ini"],
                                           cwd=here)
         p.run()
         returncode = p.poll()
 
         self.assertEqual(returncode, None)
 
-        detected, output = proctest.check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              returncode,
-                              p.didTimeout,
-                              True)
+        self.determine_status(p, True)
         p.kill()
 
     def test_poll_after_kill(self):
         """Process is killed, and poll() is called"""
 
         p = processhandler.ProcessHandler([self.python, self.proclaunch,
                                           "process_normal_finish_python.ini"],
                                           cwd=here)
         p.run()
         returncode = p.kill()
 
         # We killed the process, so the returncode should be < 0
         self.assertLess(returncode, 0)
         self.assertEqual(returncode, p.poll())
 
-        detected, output = proctest.check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              returncode,
-                              p.didTimeout)
+        self.determine_status(p)
 
     def test_poll_after_kill_no_process_group(self):
         """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)
         self.assertEqual(returncode, p.poll())
 
-        detected, output = proctest.check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              returncode,
-                              p.didTimeout)
+        self.determine_status(p)
 
     def test_poll_after_double_kill(self):
         """Process is killed twice, and poll() is called"""
 
         p = processhandler.ProcessHandler([self.python, self.proclaunch,
                                           "process_normal_finish_python.ini"],
                                           cwd=here)
         p.run()
         p.kill()
         returncode = p.kill()
 
         # We killed the process, so the returncode should be < 0
         self.assertLess(returncode, 0)
         self.assertEqual(returncode, p.poll())
 
-        detected, output = proctest.check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              returncode,
-                              p.didTimeout)
+        self.determine_status(p)
 
     def test_poll_after_external_kill(self):
         """Process is killed externally, and poll() is called"""
 
         p = processhandler.ProcessHandler([self.python, self.proclaunch,
                                           "process_normal_finish_python.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)
         self.assertEqual(returncode, p.poll())
 
-        detected, output = proctest.check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              returncode,
-                              p.didTimeout)
+        self.determine_status(p)
 
 
 if __name__ == '__main__':
     unittest.main()
--- a/testing/mozbase/mozprocess/tests/test_mozprocess_wait.py
+++ b/testing/mozbase/mozprocess/tests/test_mozprocess_wait.py
@@ -14,110 +14,81 @@ class ProcTestWait(proctest.ProcTest):
     def test_normal_finish(self):
         """Process is started, runs to completion while we wait for it"""
 
         p = processhandler.ProcessHandler([self.python, self.proclaunch, "process_normal_finish_python.ini"],
                                           cwd=here)
         p.run()
         p.wait()
 
-        detected, output = proctest.check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              p.proc.returncode,
-                              p.didTimeout)
+        self.determine_status(p)
 
     def test_wait(self):
         """Process is started runs to completion while we wait indefinitely"""
 
         p = processhandler.ProcessHandler([self.python, self.proclaunch,
                                           "process_waittimeout_10s_python.ini"],
                                           cwd=here)
         p.run()
         p.wait()
 
-        detected, output = proctest.check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              p.proc.returncode,
-                              p.didTimeout)
+        self.determine_status(p)
 
 
     def test_timeout(self):
         """ Process is started, runs but we time out waiting on it
             to complete
         """
         p = processhandler.ProcessHandler([self.python, self.proclaunch, "process_waittimeout_python.ini"],
                                           cwd=here)
         p.run(timeout=10)
         p.wait()
 
-        detected, output = proctest.check_for_process(self.proclaunch)
-
         if mozinfo.isUnix:
             # process was killed, so returncode should be negative
             self.assertLess(p.proc.returncode, 0)
 
-        self.determine_status(detected,
-                              output,
-                              p.proc.returncode,
-                              p.didTimeout,
-                              False,
-                              ['returncode', 'didtimeout'])
+        self.determine_status(p, False, ['returncode', 'didtimeout'])
 
     def test_waittimeout(self):
         """
         Process is started, then wait is called and times out.
         Process is still running and didn't timeout
         """
         p = processhandler.ProcessHandler([self.python, self.proclaunch,
                                           "process_waittimeout_10s_python.ini"],
                                           cwd=here)
 
         p.run()
         p.wait(timeout=5)
 
-        detected, output = proctest.check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              p.proc.returncode,
-                              p.didTimeout,
-                              True,
-                              ())
+        self.determine_status(p, True, ())
 
     def test_waitnotimeout(self):
         """ Process is started, runs to completion before our wait times out
         """
         p = processhandler.ProcessHandler([self.python, self.proclaunch,
                                           "process_waittimeout_10s_python.ini"],
                                           cwd=here)
         p.run(timeout=30)
         p.wait()
 
-        detected, output = proctest.check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              p.proc.returncode,
-                              p.didTimeout)
+        self.determine_status(p)
 
     def test_wait_twice_after_kill(self):
         """Bug 968718: Process is started and stopped. wait() twice afterward."""
         p = processhandler.ProcessHandler([self.python, self.proclaunch,
                                           "process_waittimeout_python.ini"],
                                           cwd=here)
         p.run()
         p.kill()
         returncode1 = p.wait()
         returncode2 = p.wait()
 
-        detected, output = proctest.check_for_process(self.proclaunch)
-        self.determine_status(detected,
-                              output,
-                              returncode2,
-                              p.didTimeout)
+        self.determine_status(p)
 
         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__':
     unittest.main()