Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_wait4.py @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | 57044a3652d8 |
| children | e3fd5fc5dc47 |
| rev | line source |
|---|---|
|
37099
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
1 """This test checks for correct wait4() behavior. |
|
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
2 """ |
|
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
3 |
|
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
4 import os |
| 39032 | 5 import time |
|
37099
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
6 from test.fork_wait import ForkWait |
|
52626
57044a3652d8
Fix Windows test skip error revealed by buildbot. Also a comment spelling
R. David Murray <rdmurray@bitdance.com>
parents:
52355
diff
changeset
|
7 from test.test_support import run_unittest, reap_children, get_attribute |
|
37099
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
8 |
|
52626
57044a3652d8
Fix Windows test skip error revealed by buildbot. Also a comment spelling
R. David Murray <rdmurray@bitdance.com>
parents:
52355
diff
changeset
|
9 # If either of these do not exist, skip this test. |
|
57044a3652d8
Fix Windows test skip error revealed by buildbot. Also a comment spelling
R. David Murray <rdmurray@bitdance.com>
parents:
52355
diff
changeset
|
10 get_attribute(os, 'fork') |
|
57044a3652d8
Fix Windows test skip error revealed by buildbot. Also a comment spelling
R. David Murray <rdmurray@bitdance.com>
parents:
52355
diff
changeset
|
11 get_attribute(os, 'wait4') |
|
37099
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
12 |
|
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
13 |
|
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
14 class Wait4Test(ForkWait): |
|
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
15 def wait_impl(self, cpid): |
| 39032 | 16 for i in range(10): |
| 17 # wait4() shouldn't hang, but some of the buildbots seem to hang | |
| 18 # in the forking tests. This is an attempt to fix the problem. | |
| 19 spid, status, rusage = os.wait4(cpid, os.WNOHANG) | |
| 20 if spid == cpid: | |
| 21 break | |
| 22 time.sleep(1.0) | |
|
37099
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
23 self.assertEqual(spid, cpid) |
|
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
24 self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8)) |
|
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
25 self.assertTrue(rusage) |
|
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
26 |
|
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
27 def test_main(): |
|
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
28 run_unittest(Wait4Test) |
|
38961
0a83dc3529d1
Add new utility function, reap_children(), to test_support. This should
Neal Norwitz <nnorwitz@gmail.com>
parents:
38869
diff
changeset
|
29 reap_children() |
|
37099
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
30 |
|
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
31 if __name__ == "__main__": |
|
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
32 test_main() |
