gecko-dev/testing/mozbase/mozprocess/tests/test_mozprocess_wait.py

102 строки
3.2 KiB
Python
Исходник Обычный вид История

#!/usr/bin/env python
from __future__ import absolute_import
import os
import proctest
import mozinfo
import mozunit
from mozprocess import processhandler
here = os.path.dirname(os.path.abspath(__file__))
Bug 1280573 - Add testing/mozbase to flake8 linter: r=ahal added testing/mozbase to tools/lint/flake8.lint fixed a first batch of PEP8 errors/warnings at first the commad autopep8 -i --max-line-length 99 -r -j 8 . has been used to fix simpler problems, run from testing/mozbase some of the issues can not easily fixed : - undefined 'names' in code for example isLinux - isLinux and isBsd "fixed" with # noqa - undefined 'message' resolved with return fmt.format(... - undefined 'structured' resolved replacing those with mozlog - long comments - some remaining - addressed with # noqa - package level import everything - addressed with # flake8: noqa restored testing/mozbase/mozdevice/mozdevice/Zeroconf.py fixed issues reported on mozreview fixed ')' in testing/mozbase/mozprocess/mozprocess/qijo.py imports finally fixed multiline string at testing/mozbase/manifestparser/tests/test_manifestparser.py:114 ^^^ and again, but now with ./mach python-test --path-only testing/mozbase/manifestparser/tests/test_manifestparser.py passing fixed testing/mozbase/manifestparser/tests/test_convert_directory.py assert fixed this error: 10:15:21 INFO - return lambda line: stack_fixer_module.fixSymbols(line) 10:15:21 INFO - TypeError: fixSymbols() takes exactly 2 arguments (1 given) fixed two spaces lint error even of # noqa comments restored assignement to lambda with # noqa to silence the lint error global noqa for testing/mozbase/manifestparser/tests/test_filters.py stupid is/is not error... MozReview-Commit-ID: 1FpJF54GqIi --HG-- extra : rebase_source : 3cf0277fb36a296e3506aeacc2ff05e1b03f9eac
2016-09-30 17:08:37 +03:00
class ProcTestWait(proctest.ProcTest):
""" Class to test process waits and timeouts """
def test_normal_finish(self):
"""Process is started, runs to completion while we wait for it"""
Bug 1280573 - Add testing/mozbase to flake8 linter: r=ahal added testing/mozbase to tools/lint/flake8.lint fixed a first batch of PEP8 errors/warnings at first the commad autopep8 -i --max-line-length 99 -r -j 8 . has been used to fix simpler problems, run from testing/mozbase some of the issues can not easily fixed : - undefined 'names' in code for example isLinux - isLinux and isBsd "fixed" with # noqa - undefined 'message' resolved with return fmt.format(... - undefined 'structured' resolved replacing those with mozlog - long comments - some remaining - addressed with # noqa - package level import everything - addressed with # flake8: noqa restored testing/mozbase/mozdevice/mozdevice/Zeroconf.py fixed issues reported on mozreview fixed ')' in testing/mozbase/mozprocess/mozprocess/qijo.py imports finally fixed multiline string at testing/mozbase/manifestparser/tests/test_manifestparser.py:114 ^^^ and again, but now with ./mach python-test --path-only testing/mozbase/manifestparser/tests/test_manifestparser.py passing fixed testing/mozbase/manifestparser/tests/test_convert_directory.py assert fixed this error: 10:15:21 INFO - return lambda line: stack_fixer_module.fixSymbols(line) 10:15:21 INFO - TypeError: fixSymbols() takes exactly 2 arguments (1 given) fixed two spaces lint error even of # noqa comments restored assignement to lambda with # noqa to silence the lint error global noqa for testing/mozbase/manifestparser/tests/test_filters.py stupid is/is not error... MozReview-Commit-ID: 1FpJF54GqIi --HG-- extra : rebase_source : 3cf0277fb36a296e3506aeacc2ff05e1b03f9eac
2016-09-30 17:08:37 +03:00
p = processhandler.ProcessHandler([self.python, self.proclaunch,
"process_normal_finish_python.ini"],
cwd=here)
p.run()
p.wait()
self.determine_status(p)
def test_wait(self):
"""Process is started runs to completion while we wait indefinitely"""
p = processhandler.ProcessHandler([self.python, self.proclaunch,
Bug 1280573 - Add testing/mozbase to flake8 linter: r=ahal added testing/mozbase to tools/lint/flake8.lint fixed a first batch of PEP8 errors/warnings at first the commad autopep8 -i --max-line-length 99 -r -j 8 . has been used to fix simpler problems, run from testing/mozbase some of the issues can not easily fixed : - undefined 'names' in code for example isLinux - isLinux and isBsd "fixed" with # noqa - undefined 'message' resolved with return fmt.format(... - undefined 'structured' resolved replacing those with mozlog - long comments - some remaining - addressed with # noqa - package level import everything - addressed with # flake8: noqa restored testing/mozbase/mozdevice/mozdevice/Zeroconf.py fixed issues reported on mozreview fixed ')' in testing/mozbase/mozprocess/mozprocess/qijo.py imports finally fixed multiline string at testing/mozbase/manifestparser/tests/test_manifestparser.py:114 ^^^ and again, but now with ./mach python-test --path-only testing/mozbase/manifestparser/tests/test_manifestparser.py passing fixed testing/mozbase/manifestparser/tests/test_convert_directory.py assert fixed this error: 10:15:21 INFO - return lambda line: stack_fixer_module.fixSymbols(line) 10:15:21 INFO - TypeError: fixSymbols() takes exactly 2 arguments (1 given) fixed two spaces lint error even of # noqa comments restored assignement to lambda with # noqa to silence the lint error global noqa for testing/mozbase/manifestparser/tests/test_filters.py stupid is/is not error... MozReview-Commit-ID: 1FpJF54GqIi --HG-- extra : rebase_source : 3cf0277fb36a296e3506aeacc2ff05e1b03f9eac
2016-09-30 17:08:37 +03:00
"process_waittimeout_10s_python.ini"],
cwd=here)
p.run()
p.wait()
self.determine_status(p)
def test_timeout(self):
""" Process is started, runs but we time out waiting on it
to complete
"""
Bug 1280573 - Add testing/mozbase to flake8 linter: r=ahal added testing/mozbase to tools/lint/flake8.lint fixed a first batch of PEP8 errors/warnings at first the commad autopep8 -i --max-line-length 99 -r -j 8 . has been used to fix simpler problems, run from testing/mozbase some of the issues can not easily fixed : - undefined 'names' in code for example isLinux - isLinux and isBsd "fixed" with # noqa - undefined 'message' resolved with return fmt.format(... - undefined 'structured' resolved replacing those with mozlog - long comments - some remaining - addressed with # noqa - package level import everything - addressed with # flake8: noqa restored testing/mozbase/mozdevice/mozdevice/Zeroconf.py fixed issues reported on mozreview fixed ')' in testing/mozbase/mozprocess/mozprocess/qijo.py imports finally fixed multiline string at testing/mozbase/manifestparser/tests/test_manifestparser.py:114 ^^^ and again, but now with ./mach python-test --path-only testing/mozbase/manifestparser/tests/test_manifestparser.py passing fixed testing/mozbase/manifestparser/tests/test_convert_directory.py assert fixed this error: 10:15:21 INFO - return lambda line: stack_fixer_module.fixSymbols(line) 10:15:21 INFO - TypeError: fixSymbols() takes exactly 2 arguments (1 given) fixed two spaces lint error even of # noqa comments restored assignement to lambda with # noqa to silence the lint error global noqa for testing/mozbase/manifestparser/tests/test_filters.py stupid is/is not error... MozReview-Commit-ID: 1FpJF54GqIi --HG-- extra : rebase_source : 3cf0277fb36a296e3506aeacc2ff05e1b03f9eac
2016-09-30 17:08:37 +03:00
p = processhandler.ProcessHandler([self.python, self.proclaunch,
"process_waittimeout_python.ini"],
cwd=here)
p.run(timeout=10)
p.wait()
if mozinfo.isUnix:
# process was killed, so returncode should be negative
self.assertLess(p.proc.returncode, 0)
self.determine_status(p, False, ['returncode', 'didtimeout'])
def test_waittimeout(self):
"""
Process is started, then wait is called and times out.
Process is still running and didn't timeout
"""
p = processhandler.ProcessHandler([self.python, self.proclaunch,
Bug 1280573 - Add testing/mozbase to flake8 linter: r=ahal added testing/mozbase to tools/lint/flake8.lint fixed a first batch of PEP8 errors/warnings at first the commad autopep8 -i --max-line-length 99 -r -j 8 . has been used to fix simpler problems, run from testing/mozbase some of the issues can not easily fixed : - undefined 'names' in code for example isLinux - isLinux and isBsd "fixed" with # noqa - undefined 'message' resolved with return fmt.format(... - undefined 'structured' resolved replacing those with mozlog - long comments - some remaining - addressed with # noqa - package level import everything - addressed with # flake8: noqa restored testing/mozbase/mozdevice/mozdevice/Zeroconf.py fixed issues reported on mozreview fixed ')' in testing/mozbase/mozprocess/mozprocess/qijo.py imports finally fixed multiline string at testing/mozbase/manifestparser/tests/test_manifestparser.py:114 ^^^ and again, but now with ./mach python-test --path-only testing/mozbase/manifestparser/tests/test_manifestparser.py passing fixed testing/mozbase/manifestparser/tests/test_convert_directory.py assert fixed this error: 10:15:21 INFO - return lambda line: stack_fixer_module.fixSymbols(line) 10:15:21 INFO - TypeError: fixSymbols() takes exactly 2 arguments (1 given) fixed two spaces lint error even of # noqa comments restored assignement to lambda with # noqa to silence the lint error global noqa for testing/mozbase/manifestparser/tests/test_filters.py stupid is/is not error... MozReview-Commit-ID: 1FpJF54GqIi --HG-- extra : rebase_source : 3cf0277fb36a296e3506aeacc2ff05e1b03f9eac
2016-09-30 17:08:37 +03:00
"process_waittimeout_10s_python.ini"],
cwd=here)
p.run()
p.wait(timeout=5)
self.determine_status(p, True, ())
def test_waitnotimeout(self):
""" Process is started, runs to completion before our wait times out
"""
p = processhandler.ProcessHandler([self.python, self.proclaunch,
Bug 1280573 - Add testing/mozbase to flake8 linter: r=ahal added testing/mozbase to tools/lint/flake8.lint fixed a first batch of PEP8 errors/warnings at first the commad autopep8 -i --max-line-length 99 -r -j 8 . has been used to fix simpler problems, run from testing/mozbase some of the issues can not easily fixed : - undefined 'names' in code for example isLinux - isLinux and isBsd "fixed" with # noqa - undefined 'message' resolved with return fmt.format(... - undefined 'structured' resolved replacing those with mozlog - long comments - some remaining - addressed with # noqa - package level import everything - addressed with # flake8: noqa restored testing/mozbase/mozdevice/mozdevice/Zeroconf.py fixed issues reported on mozreview fixed ')' in testing/mozbase/mozprocess/mozprocess/qijo.py imports finally fixed multiline string at testing/mozbase/manifestparser/tests/test_manifestparser.py:114 ^^^ and again, but now with ./mach python-test --path-only testing/mozbase/manifestparser/tests/test_manifestparser.py passing fixed testing/mozbase/manifestparser/tests/test_convert_directory.py assert fixed this error: 10:15:21 INFO - return lambda line: stack_fixer_module.fixSymbols(line) 10:15:21 INFO - TypeError: fixSymbols() takes exactly 2 arguments (1 given) fixed two spaces lint error even of # noqa comments restored assignement to lambda with # noqa to silence the lint error global noqa for testing/mozbase/manifestparser/tests/test_filters.py stupid is/is not error... MozReview-Commit-ID: 1FpJF54GqIi --HG-- extra : rebase_source : 3cf0277fb36a296e3506aeacc2ff05e1b03f9eac
2016-09-30 17:08:37 +03:00
"process_waittimeout_10s_python.ini"],
cwd=here)
p.run(timeout=30)
p.wait()
self.determine_status(p)
def test_wait_twice_after_kill(self):
"""Bug 968718: Process is started and stopped. wait() twice afterward."""
p = processhandler.ProcessHandler([self.python, self.proclaunch,
Bug 1280573 - Add testing/mozbase to flake8 linter: r=ahal added testing/mozbase to tools/lint/flake8.lint fixed a first batch of PEP8 errors/warnings at first the commad autopep8 -i --max-line-length 99 -r -j 8 . has been used to fix simpler problems, run from testing/mozbase some of the issues can not easily fixed : - undefined 'names' in code for example isLinux - isLinux and isBsd "fixed" with # noqa - undefined 'message' resolved with return fmt.format(... - undefined 'structured' resolved replacing those with mozlog - long comments - some remaining - addressed with # noqa - package level import everything - addressed with # flake8: noqa restored testing/mozbase/mozdevice/mozdevice/Zeroconf.py fixed issues reported on mozreview fixed ')' in testing/mozbase/mozprocess/mozprocess/qijo.py imports finally fixed multiline string at testing/mozbase/manifestparser/tests/test_manifestparser.py:114 ^^^ and again, but now with ./mach python-test --path-only testing/mozbase/manifestparser/tests/test_manifestparser.py passing fixed testing/mozbase/manifestparser/tests/test_convert_directory.py assert fixed this error: 10:15:21 INFO - return lambda line: stack_fixer_module.fixSymbols(line) 10:15:21 INFO - TypeError: fixSymbols() takes exactly 2 arguments (1 given) fixed two spaces lint error even of # noqa comments restored assignement to lambda with # noqa to silence the lint error global noqa for testing/mozbase/manifestparser/tests/test_filters.py stupid is/is not error... MozReview-Commit-ID: 1FpJF54GqIi --HG-- extra : rebase_source : 3cf0277fb36a296e3506aeacc2ff05e1b03f9eac
2016-09-30 17:08:37 +03:00
"process_waittimeout_python.ini"],
cwd=here)
p.run()
p.kill()
returncode1 = p.wait()
returncode2 = p.wait()
self.determine_status(p)
self.assertLess(returncode2, 0,
'Negative returncode expected, got "%s"' % returncode2)
self.assertEqual(returncode1, returncode2,
'Expected both returncodes of wait() to be equal')
if __name__ == '__main__':
mozunit.main()