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 | |
michael@0 | 3 | import os |
michael@0 | 4 | import time |
michael@0 | 5 | import unittest |
michael@0 | 6 | import proctest |
michael@0 | 7 | from mozprocess import processhandler |
michael@0 | 8 | |
michael@0 | 9 | here = os.path.dirname(os.path.abspath(__file__)) |
michael@0 | 10 | |
michael@0 | 11 | class ProcTestKill(proctest.ProcTest): |
michael@0 | 12 | """ Class to test various process tree killing scenatios """ |
michael@0 | 13 | |
michael@0 | 14 | def test_process_kill(self): |
michael@0 | 15 | """Process is started, we kill it""" |
michael@0 | 16 | |
michael@0 | 17 | p = processhandler.ProcessHandler([self.python, self.proclaunch, "process_normal_finish_python.ini"], |
michael@0 | 18 | cwd=here) |
michael@0 | 19 | p.run() |
michael@0 | 20 | p.kill() |
michael@0 | 21 | |
michael@0 | 22 | detected, output = proctest.check_for_process(self.proclaunch) |
michael@0 | 23 | self.determine_status(detected, |
michael@0 | 24 | output, |
michael@0 | 25 | p.proc.returncode, |
michael@0 | 26 | p.didTimeout, |
michael@0 | 27 | expectedfail=('returncode',)) |
michael@0 | 28 | |
michael@0 | 29 | def test_process_kill_deep(self): |
michael@0 | 30 | """Process is started, we kill it, we use a deep process tree""" |
michael@0 | 31 | |
michael@0 | 32 | p = processhandler.ProcessHandler([self.python, self.proclaunch, "process_normal_deep_python.ini"], |
michael@0 | 33 | cwd=here) |
michael@0 | 34 | p.run() |
michael@0 | 35 | p.kill() |
michael@0 | 36 | |
michael@0 | 37 | detected, output = proctest.check_for_process(self.proclaunch) |
michael@0 | 38 | self.determine_status(detected, |
michael@0 | 39 | output, |
michael@0 | 40 | p.proc.returncode, |
michael@0 | 41 | p.didTimeout, |
michael@0 | 42 | expectedfail=('returncode',)) |
michael@0 | 43 | |
michael@0 | 44 | def test_process_kill_deep_wait(self): |
michael@0 | 45 | """Process is started, we use a deep process tree, we let it spawn |
michael@0 | 46 | for a bit, we kill it""" |
michael@0 | 47 | |
michael@0 | 48 | p = processhandler.ProcessHandler([self.python, self.proclaunch, "process_normal_deep_python.ini"], |
michael@0 | 49 | cwd=here) |
michael@0 | 50 | p.run() |
michael@0 | 51 | # Let the tree spawn a bit, before attempting to kill |
michael@0 | 52 | time.sleep(3) |
michael@0 | 53 | p.kill() |
michael@0 | 54 | |
michael@0 | 55 | detected, output = proctest.check_for_process(self.proclaunch) |
michael@0 | 56 | self.determine_status(detected, |
michael@0 | 57 | output, |
michael@0 | 58 | p.proc.returncode, |
michael@0 | 59 | p.didTimeout, |
michael@0 | 60 | expectedfail=('returncode',)) |
michael@0 | 61 | |
michael@0 | 62 | def test_process_kill_broad(self): |
michael@0 | 63 | """Process is started, we kill it, we use a broad process tree""" |
michael@0 | 64 | |
michael@0 | 65 | p = processhandler.ProcessHandler([self.python, self.proclaunch, "process_normal_broad_python.ini"], |
michael@0 | 66 | cwd=here) |
michael@0 | 67 | p.run() |
michael@0 | 68 | p.kill() |
michael@0 | 69 | |
michael@0 | 70 | detected, output = proctest.check_for_process(self.proclaunch) |
michael@0 | 71 | self.determine_status(detected, |
michael@0 | 72 | output, |
michael@0 | 73 | p.proc.returncode, |
michael@0 | 74 | p.didTimeout, |
michael@0 | 75 | expectedfail=('returncode',)) |
michael@0 | 76 | |
michael@0 | 77 | if __name__ == '__main__': |
michael@0 | 78 | unittest.main() |