1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/testing/mozbase/mozrunner/tests/test_stop.py Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,40 @@ 1.4 +#!/usr/bin/env python 1.5 +# This Source Code Form is subject to the terms of the Mozilla Public 1.6 +# License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.7 +# You can obtain one at http://mozilla.org/MPL/2.0/. 1.8 + 1.9 +import os 1.10 +import signal 1.11 + 1.12 +import mozrunnertest 1.13 + 1.14 + 1.15 +class MozrunnerStopTestCase(mozrunnertest.MozrunnerTestCase): 1.16 + 1.17 + def test_stop_process(self): 1.18 + """Stop the process and test properties""" 1.19 + self.runner.start() 1.20 + returncode = self.runner.stop() 1.21 + 1.22 + self.assertFalse(self.runner.is_running()) 1.23 + self.assertNotIn(returncode, [None, 0]) 1.24 + self.assertEqual(self.runner.returncode, returncode) 1.25 + self.assertIsNotNone(self.runner.process_handler) 1.26 + 1.27 + self.assertEqual(self.runner.wait(1), returncode) 1.28 + 1.29 + def test_stop_before_start(self): 1.30 + """Stop the process before it gets started should not raise an error""" 1.31 + returncode = self.runner.stop() 1.32 + 1.33 + def test_stop_process_custom_signal(self): 1.34 + """Stop the process via a custom signal and test properties""" 1.35 + self.runner.start() 1.36 + returncode = self.runner.stop(signal.SIGTERM) 1.37 + 1.38 + self.assertFalse(self.runner.is_running()) 1.39 + self.assertNotIn(returncode, [None, 0]) 1.40 + self.assertEqual(self.runner.returncode, returncode) 1.41 + self.assertIsNotNone(self.runner.process_handler) 1.42 + 1.43 + self.assertEqual(self.runner.wait(1), returncode)