]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_wait3.py
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / test / test_wait3.py
CommitLineData
4710c53d 1"""This test checks for correct wait3() behavior.\r
2"""\r
3\r
4import os\r
5import time\r
6import unittest\r
7from test.fork_wait import ForkWait\r
8from test.test_support import run_unittest, reap_children\r
9\r
10try:\r
11 os.fork\r
12except AttributeError:\r
13 raise unittest.SkipTest, "os.fork not defined -- skipping test_wait3"\r
14\r
15try:\r
16 os.wait3\r
17except AttributeError:\r
18 raise unittest.SkipTest, "os.wait3 not defined -- skipping test_wait3"\r
19\r
20class 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
34def test_main():\r
35 run_unittest(Wait3Test)\r
36 reap_children()\r
37\r
38if __name__ == "__main__":\r
39 test_main()\r