|
1 #!/usr/bin/env python |
|
2 # This Source Code Form is subject to the terms of the Mozilla Public |
|
3 # License, v. 2.0. If a copy of the MPL was not distributed with this file, |
|
4 # You can obtain one at http://mozilla.org/MPL/2.0/. |
|
5 |
|
6 import os |
|
7 import signal |
|
8 |
|
9 import mozrunnertest |
|
10 |
|
11 |
|
12 class MozrunnerStopTestCase(mozrunnertest.MozrunnerTestCase): |
|
13 |
|
14 def test_stop_process(self): |
|
15 """Stop the process and test properties""" |
|
16 self.runner.start() |
|
17 returncode = self.runner.stop() |
|
18 |
|
19 self.assertFalse(self.runner.is_running()) |
|
20 self.assertNotIn(returncode, [None, 0]) |
|
21 self.assertEqual(self.runner.returncode, returncode) |
|
22 self.assertIsNotNone(self.runner.process_handler) |
|
23 |
|
24 self.assertEqual(self.runner.wait(1), returncode) |
|
25 |
|
26 def test_stop_before_start(self): |
|
27 """Stop the process before it gets started should not raise an error""" |
|
28 returncode = self.runner.stop() |
|
29 |
|
30 def test_stop_process_custom_signal(self): |
|
31 """Stop the process via a custom signal and test properties""" |
|
32 self.runner.start() |
|
33 returncode = self.runner.stop(signal.SIGTERM) |
|
34 |
|
35 self.assertFalse(self.runner.is_running()) |
|
36 self.assertNotIn(returncode, [None, 0]) |
|
37 self.assertEqual(self.runner.returncode, returncode) |
|
38 self.assertIsNotNone(self.runner.process_handler) |
|
39 |
|
40 self.assertEqual(self.runner.wait(1), returncode) |