michael@0: #!/usr/bin/env python michael@0: michael@0: import os michael@0: from time import sleep michael@0: import unittest michael@0: michael@0: import mozrunnertest michael@0: michael@0: michael@0: class MozrunnerStartTestCase(mozrunnertest.MozrunnerTestCase): michael@0: michael@0: def test_start_process(self): michael@0: """Start the process and test properties""" michael@0: self.assertIsNone(self.runner.process_handler) michael@0: michael@0: self.runner.start() michael@0: michael@0: self.assertTrue(self.runner.is_running()) michael@0: self.assertIsNotNone(self.runner.process_handler) michael@0: michael@0: def test_start_process_called_twice(self): michael@0: """Start the process twice and test that first process is gone""" michael@0: pid1 = self.runner.start() michael@0: # Bug 925480 michael@0: # Make a copy until mozprocess can kill a specific process michael@0: process_handler = self.runner.process_handler michael@0: michael@0: pid2 = self.runner.start() michael@0: michael@0: try: michael@0: self.assertNotIn(process_handler.wait(1), [None, 0]) michael@0: finally: michael@0: process_handler.kill() michael@0: michael@0: def test_start_with_timeout(self): michael@0: """Start the process and set a timeout""" michael@0: self.runner.start(timeout=2) michael@0: sleep(5) michael@0: michael@0: self.assertFalse(self.runner.is_running()) michael@0: michael@0: def test_start_with_outputTimeout(self): michael@0: """Start the process and set a timeout""" michael@0: self.runner.start(outputTimeout=2) michael@0: sleep(5) michael@0: michael@0: self.assertFalse(self.runner.is_running())