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