Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_wait3.py @ 58925:eecf1bef052d 2.6
Merged revisions 78207 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line
#7930: fix stripid
........
| author | Ezio Melotti <ezio.melotti@gmail.com> |
|---|---|
| date | Tue, 16 Feb 2010 23:29:44 +0000 |
| parents | b3c0e0759ac0 |
| children | e6009b9cd908 |
| 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 wait3() 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 |
|
38961
0a83dc3529d1
Add new utility function, reap_children(), to test_support. This should
Neal Norwitz <nnorwitz@gmail.com>
parents:
38869
diff
changeset
|
7 from test.test_support import TestSkipped, run_unittest, 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
|
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
|
9 try: |
|
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
10 os.fork |
|
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
11 except AttributeError: |
|
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 raise TestSkipped, "os.fork not defined -- skipping test_wait3" |
|
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 try: |
|
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 os.wait3 |
|
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
16 except AttributeError: |
|
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
17 raise TestSkipped, "os.wait3 not defined -- skipping test_wait3" |
|
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
18 |
|
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
19 class Wait3Test(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
|
20 def wait_impl(self, cpid): |
| 39032 | 21 for i in range(10): |
| 22 # wait3() shouldn't hang, but some of the buildbots seem to hang | |
| 23 # in the forking tests. This is an attempt to fix the problem. | |
| 24 spid, status, rusage = os.wait3(os.WNOHANG) | |
| 37104 | 25 if spid == cpid: |
| 26 break | |
| 39032 | 27 time.sleep(1.0) |
| 28 | |
|
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
|
29 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
|
30 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
|
31 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
|
32 |
|
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
33 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
|
34 run_unittest(Wait3Test) |
|
38961
0a83dc3529d1
Add new utility function, reap_children(), to test_support. This should
Neal Norwitz <nnorwitz@gmail.com>
parents:
38869
diff
changeset
|
35 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
|
36 |
|
d62b13488943
Patch #1309579: wait3 and wait4 were added to the posix module by Chad J. Schroeder.
Neal Norwitz <nnorwitz@gmail.com>
parents:
diff
changeset
|
37 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
|
38 test_main() |
