blob: 82799732fe5e040692161a9555040f912e103cf8 [file] [log] [blame]
Neal Norwitz05a45592006-03-20 06:30:08 +00001"""This test checks for correct wait3() behavior.
2"""
3
4import os
5from test.fork_wait import ForkWait
Neal Norwitzb15ac312006-06-29 04:10:08 +00006from test.test_support import TestSkipped, run_unittest, reap_children
Neal Norwitz05a45592006-03-20 06:30:08 +00007
8try:
9 os.fork
10except AttributeError:
11 raise TestSkipped, "os.fork not defined -- skipping test_wait3"
12
13try:
14 os.wait3
15except AttributeError:
16 raise TestSkipped, "os.wait3 not defined -- skipping test_wait3"
17
18class Wait3Test(ForkWait):
19 def wait_impl(self, cpid):
Neal Norwitz0f51cf62006-06-18 20:10:24 +000020 while 1:
21 spid, status, rusage = os.wait3(0)
Anthony Baxter46fa48a2006-03-20 07:10:01 +000022 if spid == cpid:
23 break
Neal Norwitz05a45592006-03-20 06:30:08 +000024 self.assertEqual(spid, cpid)
25 self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8))
26 self.assertTrue(rusage)
27
28def test_main():
29 run_unittest(Wait3Test)
Neal Norwitzb15ac312006-06-29 04:10:08 +000030 reap_children()
Neal Norwitz05a45592006-03-20 06:30:08 +000031
32if __name__ == "__main__":
33 test_main()