source: python/trunk/Lib/test/test_wait3.py

Last change on this file was 391, checked in by dmik, 11 years ago

python: Merge vendor 2.7.6 to trunk.

  • Property svn:eol-style set to native
File size: 1.0 KB
Line 
1"""This test checks for correct wait3() behavior.
2"""
3
4import os
5import time
6import unittest
7from test.fork_wait import ForkWait
8from test.test_support import run_unittest, reap_children
9
10try:
11 os.fork
12except AttributeError:
13 raise unittest.SkipTest, "os.fork not defined -- skipping test_wait3"
14
15try:
16 os.wait3
17except AttributeError:
18 raise unittest.SkipTest, "os.wait3 not defined -- skipping test_wait3"
19
20class Wait3Test(ForkWait):
21 def wait_impl(self, cpid):
22 for i in range(10):
23 # wait3() shouldn't hang, but some of the buildbots seem to hang
24 # in the forking tests. This is an attempt to fix the problem.
25 spid, status, rusage = os.wait3(os.WNOHANG)
26 if spid == cpid:
27 break
28 time.sleep(1.0)
29
30 self.assertEqual(spid, cpid)
31 self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8))
32 self.assertTrue(rusage)
33
34def test_main():
35 run_unittest(Wait3Test)
36 reap_children()
37
38if __name__ == "__main__":
39 test_main()
Note: See TracBrowser for help on using the repository browser.