summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_bz2.py1
-rw-r--r--Lib/test/test_cmd_line.py1
-rw-r--r--Lib/test/test_commands.py3
-rw-r--r--Lib/test/test_fork1.py3
-rw-r--r--Lib/test/test_mailbox.py1
-rw-r--r--Lib/test/test_popen.py3
-rw-r--r--Lib/test/test_popen2.py3
-rw-r--r--Lib/test/test_select.py3
-rw-r--r--Lib/test/test_socketserver.py4
-rw-r--r--Lib/test/test_subprocess.py11
-rw-r--r--Lib/test/test_support.py21
-rw-r--r--Lib/test/test_wait3.py3
-rw-r--r--Lib/test/test_wait4.py3
13 files changed, 52 insertions, 8 deletions
diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py
index 504a6d7..79acc07 100644
--- a/Lib/test/test_bz2.py
+++ b/Lib/test/test_bz2.py
@@ -352,6 +352,7 @@ def test_main():
BZ2DecompressorTest,
FuncTest
)
+ test_support.reap_children()
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py
index ec860d1..5e89863 100644
--- a/Lib/test/test_cmd_line.py
+++ b/Lib/test/test_cmd_line.py
@@ -87,6 +87,7 @@ class CmdLineTest(unittest.TestCase):
def test_main():
test.test_support.run_unittest(CmdLineTest)
+ test.test_support.reap_children()
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_commands.py b/Lib/test/test_commands.py
index 0f7d15f..b72a1b9 100644
--- a/Lib/test/test_commands.py
+++ b/Lib/test/test_commands.py
@@ -5,7 +5,7 @@
import unittest
import os, tempfile, re
-from test.test_support import TestSkipped, run_unittest
+from test.test_support import TestSkipped, run_unittest, reap_children
from commands import *
# The module says:
@@ -58,6 +58,7 @@ class CommandTests(unittest.TestCase):
def test_main():
run_unittest(CommandTests)
+ reap_children()
if __name__ == "__main__":
diff --git a/Lib/test/test_fork1.py b/Lib/test/test_fork1.py
index cba5fc7..e909844 100644
--- a/Lib/test/test_fork1.py
+++ b/Lib/test/test_fork1.py
@@ -3,7 +3,7 @@
import os
from test.fork_wait import ForkWait
-from test.test_support import TestSkipped, run_unittest
+from test.test_support import TestSkipped, run_unittest, reap_children
try:
os.fork
@@ -18,6 +18,7 @@ class ForkTest(ForkWait):
def test_main():
run_unittest(ForkTest)
+ reap_children()
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
index 474354f..2f8cb8d 100644
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -1785,6 +1785,7 @@ def test_main():
TestMessageConversion, TestProxyFile, TestPartialFile,
MaildirTestCase)
test_support.run_unittest(*tests)
+ test_support.reap_children()
if __name__ == '__main__':
diff --git a/Lib/test/test_popen.py b/Lib/test/test_popen.py
index 2b687ad..fbf5e05 100644
--- a/Lib/test/test_popen.py
+++ b/Lib/test/test_popen.py
@@ -6,7 +6,7 @@
import os
import sys
-from test.test_support import TestSkipped
+from test.test_support import TestSkipped, reap_children
from os import popen
# Test that command-lines get down as we expect.
@@ -35,5 +35,6 @@ def _test_commandline():
def main():
print "Test popen:"
_test_commandline()
+ reap_children()
main()
diff --git a/Lib/test/test_popen2.py b/Lib/test/test_popen2.py
index 4db3cd1..2d54eb0 100644
--- a/Lib/test/test_popen2.py
+++ b/Lib/test/test_popen2.py
@@ -5,7 +5,7 @@
import os
import sys
-from test.test_support import TestSkipped
+from test.test_support import TestSkipped, reap_children
# popen2 contains its own testing routine
# which is especially useful to see if open files
@@ -75,3 +75,4 @@ def _test():
main()
_test()
+reap_children()
diff --git a/Lib/test/test_select.py b/Lib/test/test_select.py
index eaec52b..d341324 100644
--- a/Lib/test/test_select.py
+++ b/Lib/test/test_select.py
@@ -1,5 +1,5 @@
# Testing select module
-from test.test_support import verbose
+from test.test_support import verbose, reap_children
import select
import os
@@ -65,5 +65,6 @@ def test():
continue
print 'Unexpected return values from select():', rfd, wfd, xfd
p.close()
+ reap_children()
test()
diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py
index 9316547..dd4532f 100644
--- a/Lib/test/test_socketserver.py
+++ b/Lib/test/test_socketserver.py
@@ -1,7 +1,8 @@
# Test suite for SocketServer.py
from test import test_support
-from test.test_support import verbose, verify, TESTFN, TestSkipped
+from test.test_support import (verbose, verify, TESTFN, TestSkipped,
+ reap_children)
test_support.requires('network')
from SocketServer import *
@@ -199,6 +200,7 @@ def test_main():
testall()
finally:
cleanup()
+ reap_children()
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 9877f51..b4e6c00 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -27,6 +27,16 @@ def remove_stderr_debug_decorations(stderr):
return re.sub(r"\[\d+ refs\]\r?\n?$", "", stderr)
class ProcessTestCase(unittest.TestCase):
+ def setUp(self):
+ # Try to minimize the number of children we have so this test
+ # doesn't crash on some buildbots (Alphas in particular).
+ test_support.reap_children()
+
+ def tearDown(self):
+ # Try to minimize the number of children we have so this test
+ # doesn't crash on some buildbots (Alphas in particular).
+ test_support.reap_children()
+
def mkstemp(self):
"""wrapper for mkstemp, calling mktemp if mkstemp is not available"""
if hasattr(tempfile, "mkstemp"):
@@ -600,6 +610,7 @@ class ProcessTestCase(unittest.TestCase):
def test_main():
test_support.run_unittest(ProcessTestCase)
+ test_support.reap_children()
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index 8e31549..6532c79 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -475,3 +475,24 @@ def threading_cleanup(num_active, num_limbo):
while len(threading._limbo) != num_limbo and count < _MAX_COUNT:
count += 1
time.sleep(0.1)
+
+def reap_children():
+ """Use this function at the end of test_main() whenever sub-processes
+ are started. This will help ensure that no extra children (zombies)
+ stick around to hog resources and create problems when looking
+ for refleaks.
+ """
+
+ # Reap all our dead child processes so we don't leave zombies around.
+ # These hog resources and might be causing some of the buildbots to die.
+ import os
+ if hasattr(os, 'waitpid'):
+ any_process = -1
+ while True:
+ try:
+ # This will raise an exception on Windows. That's ok.
+ pid, status = os.waitpid(any_process, os.WNOHANG)
+ if pid == 0:
+ break
+ except:
+ break
diff --git a/Lib/test/test_wait3.py b/Lib/test/test_wait3.py
index f6a41a6..8279973 100644
--- a/Lib/test/test_wait3.py
+++ b/Lib/test/test_wait3.py
@@ -3,7 +3,7 @@
import os
from test.fork_wait import ForkWait
-from test.test_support import TestSkipped, run_unittest
+from test.test_support import TestSkipped, run_unittest, reap_children
try:
os.fork
@@ -27,6 +27,7 @@ class Wait3Test(ForkWait):
def test_main():
run_unittest(Wait3Test)
+ reap_children()
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_wait4.py b/Lib/test/test_wait4.py
index 027e5c3..711fd2d 100644
--- a/Lib/test/test_wait4.py
+++ b/Lib/test/test_wait4.py
@@ -3,7 +3,7 @@
import os
from test.fork_wait import ForkWait
-from test.test_support import TestSkipped, run_unittest
+from test.test_support import TestSkipped, run_unittest, reap_children
try:
os.fork
@@ -24,6 +24,7 @@ class Wait4Test(ForkWait):
def test_main():
run_unittest(Wait4Test)
+ reap_children()
if __name__ == "__main__":
test_main()