Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 #!/usr/bin/env python
3 import os
4 import time
5 import unittest
6 import proctest
7 from mozprocess import processhandler
9 here = os.path.dirname(os.path.abspath(__file__))
11 class ProcTestKill(proctest.ProcTest):
12 """ Class to test various process tree killing scenatios """
14 def test_process_kill(self):
15 """Process is started, we kill it"""
17 p = processhandler.ProcessHandler([self.python, self.proclaunch, "process_normal_finish_python.ini"],
18 cwd=here)
19 p.run()
20 p.kill()
22 detected, output = proctest.check_for_process(self.proclaunch)
23 self.determine_status(detected,
24 output,
25 p.proc.returncode,
26 p.didTimeout,
27 expectedfail=('returncode',))
29 def test_process_kill_deep(self):
30 """Process is started, we kill it, we use a deep process tree"""
32 p = processhandler.ProcessHandler([self.python, self.proclaunch, "process_normal_deep_python.ini"],
33 cwd=here)
34 p.run()
35 p.kill()
37 detected, output = proctest.check_for_process(self.proclaunch)
38 self.determine_status(detected,
39 output,
40 p.proc.returncode,
41 p.didTimeout,
42 expectedfail=('returncode',))
44 def test_process_kill_deep_wait(self):
45 """Process is started, we use a deep process tree, we let it spawn
46 for a bit, we kill it"""
48 p = processhandler.ProcessHandler([self.python, self.proclaunch, "process_normal_deep_python.ini"],
49 cwd=here)
50 p.run()
51 # Let the tree spawn a bit, before attempting to kill
52 time.sleep(3)
53 p.kill()
55 detected, output = proctest.check_for_process(self.proclaunch)
56 self.determine_status(detected,
57 output,
58 p.proc.returncode,
59 p.didTimeout,
60 expectedfail=('returncode',))
62 def test_process_kill_broad(self):
63 """Process is started, we kill it, we use a broad process tree"""
65 p = processhandler.ProcessHandler([self.python, self.proclaunch, "process_normal_broad_python.ini"],
66 cwd=here)
67 p.run()
68 p.kill()
70 detected, output = proctest.check_for_process(self.proclaunch)
71 self.determine_status(detected,
72 output,
73 p.proc.returncode,
74 p.didTimeout,
75 expectedfail=('returncode',))
77 if __name__ == '__main__':
78 unittest.main()