1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/testing/mozbase/mozrunner/tests/test_interactive.py Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 1.4 +#!/usr/bin/env python 1.5 + 1.6 +import os 1.7 +import threading 1.8 +from time import sleep 1.9 +import unittest 1.10 + 1.11 +import mozrunnertest 1.12 + 1.13 + 1.14 +class RunnerThread(threading.Thread): 1.15 + def __init__(self, runner, timeout=10): 1.16 + threading.Thread.__init__(self) 1.17 + self.runner = runner 1.18 + self.timeout = timeout 1.19 + 1.20 + def run(self): 1.21 + sleep(self.timeout) 1.22 + self.runner.stop() 1.23 + 1.24 + 1.25 +class MozrunnerInteractiveTestCase(mozrunnertest.MozrunnerTestCase): 1.26 + 1.27 + def test_run_interactive(self): 1.28 + """Bug 965183: Run process in interactive mode and call wait()""" 1.29 + pid = self.runner.start(interactive=True) 1.30 + self.pids.append(pid) 1.31 + 1.32 + thread = RunnerThread(self.runner, 5) 1.33 + self.threads.append(thread) 1.34 + thread.start() 1.35 + 1.36 + # This is a blocking call. So the process should be killed by the thread 1.37 + self.runner.wait() 1.38 + thread.join() 1.39 + self.assertFalse(self.runner.is_running()) 1.40 + 1.41 + def test_stop_interactive(self): 1.42 + """Bug 965183: Explicitely stop process in interactive mode""" 1.43 + pid = self.runner.start(interactive=True) 1.44 + self.pids.append(pid) 1.45 + 1.46 + self.runner.stop() 1.47 + 1.48 + def test_wait_after_process_finished(self): 1.49 + """Wait after the process has been stopped should not raise an error""" 1.50 + self.runner.start(interactive=True) 1.51 + sleep(5) 1.52 + self.runner.process_handler.kill() 1.53 + 1.54 + returncode = self.runner.wait(1) 1.55 + 1.56 + self.assertNotIn(returncode, [None, 0]) 1.57 + self.assertIsNotNone(self.runner.process_handler)