|
1 #!/usr/bin/env python |
|
2 |
|
3 import os |
|
4 from time import sleep |
|
5 import unittest |
|
6 |
|
7 import mozrunnertest |
|
8 |
|
9 |
|
10 class MozrunnerStartTestCase(mozrunnertest.MozrunnerTestCase): |
|
11 |
|
12 def test_start_process(self): |
|
13 """Start the process and test properties""" |
|
14 self.assertIsNone(self.runner.process_handler) |
|
15 |
|
16 self.runner.start() |
|
17 |
|
18 self.assertTrue(self.runner.is_running()) |
|
19 self.assertIsNotNone(self.runner.process_handler) |
|
20 |
|
21 def test_start_process_called_twice(self): |
|
22 """Start the process twice and test that first process is gone""" |
|
23 pid1 = self.runner.start() |
|
24 # Bug 925480 |
|
25 # Make a copy until mozprocess can kill a specific process |
|
26 process_handler = self.runner.process_handler |
|
27 |
|
28 pid2 = self.runner.start() |
|
29 |
|
30 try: |
|
31 self.assertNotIn(process_handler.wait(1), [None, 0]) |
|
32 finally: |
|
33 process_handler.kill() |
|
34 |
|
35 def test_start_with_timeout(self): |
|
36 """Start the process and set a timeout""" |
|
37 self.runner.start(timeout=2) |
|
38 sleep(5) |
|
39 |
|
40 self.assertFalse(self.runner.is_running()) |
|
41 |
|
42 def test_start_with_outputTimeout(self): |
|
43 """Start the process and set a timeout""" |
|
44 self.runner.start(outputTimeout=2) |
|
45 sleep(5) |
|
46 |
|
47 self.assertFalse(self.runner.is_running()) |