summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2010-03-01 00:05:08 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2010-03-01 00:05:08 (GMT)
commitcce211f88c3d23bbd37f5769e3addd9b6b9fa96e (patch)
tree5f4b5750901fe40b7ddb0965f44853e68d34e360 /Lib/test
parentfb501123e3c23c3e4f2861645d58134f307ea99b (diff)
downloadcpython-cce211f88c3d23bbd37f5769e3addd9b6b9fa96e.zip
cpython-cce211f88c3d23bbd37f5769e3addd9b6b9fa96e.tar.gz
cpython-cce211f88c3d23bbd37f5769e3addd9b6b9fa96e.tar.bz2
Issue #1068268: The subprocess module now handles EINTR in internal
os.waitpid and os.read system calls where appropriate.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_subprocess.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index c72b6e0..4e45e11 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -4,6 +4,7 @@ import subprocess
import sys
import signal
import os
+import errno
import tempfile
import time
import re
@@ -772,11 +773,30 @@ class ProcessTestCaseNoPoll(ProcessTestCase):
ProcessTestCase.tearDown(self)
+class HelperFunctionTests(unittest.TestCase):
+ def test_eintr_retry_call(self):
+ record_calls = []
+ def fake_os_func(*args):
+ record_calls.append(args)
+ if len(record_calls) == 2:
+ raise OSError(errno.EINTR, "fake interrupted system call")
+ return tuple(reversed(args))
+
+ self.assertEqual((999, 256),
+ subprocess._eintr_retry_call(fake_os_func, 256, 999))
+ self.assertEqual([(256, 999)], record_calls)
+ # This time there will be an EINTR so it will loop once.
+ self.assertEqual((666,),
+ subprocess._eintr_retry_call(fake_os_func, 666))
+ self.assertEqual([(256, 999), (666,), (666,)], record_calls)
+
+
def test_main():
unit_tests = (ProcessTestCase,
POSIXProcessTestCase,
Win32ProcessTestCase,
- ProcessTestCaseNoPoll)
+ ProcessTestCaseNoPoll,
+ HelperFunctionTests)
test_support.run_unittest(*unit_tests)
test_support.reap_children()