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