2000-02-25 15:25:05 -04:00
|
|
|
"""This test checks for correct fork() behavior.
|
|
|
|
"""
|
|
|
|
|
2006-04-21 07:40:58 -03:00
|
|
|
import os
|
|
|
|
from test.fork_wait import ForkWait
|
|
|
|
from test.test_support import TestSkipped, run_unittest
|
2000-02-25 15:25:05 -04:00
|
|
|
|
2000-05-03 21:36:42 -03:00
|
|
|
try:
|
|
|
|
os.fork
|
|
|
|
except AttributeError:
|
2000-08-04 10:34:43 -03:00
|
|
|
raise TestSkipped, "os.fork not defined -- skipping test_fork1"
|
2000-05-03 21:36:42 -03:00
|
|
|
|
2006-04-21 07:40:58 -03:00
|
|
|
class ForkTest(ForkWait):
|
|
|
|
def wait_impl(self, cpid):
|
2000-02-25 15:25:05 -04:00
|
|
|
spid, status = os.waitpid(cpid, 0)
|
2006-04-21 07:40:58 -03:00
|
|
|
self.assertEqual(spid, cpid)
|
|
|
|
self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8))
|
|
|
|
|
|
|
|
def test_main():
|
|
|
|
run_unittest(ForkTest)
|
2000-02-25 15:25:05 -04:00
|
|
|
|
2006-04-21 07:40:58 -03:00
|
|
|
if __name__ == "__main__":
|
|
|
|
test_main()
|