summaryrefslogtreecommitdiff
path: root/Lib/test
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2010-03-01 00:35:34 +0000
committerGregory P. Smith <greg@mad-scientist.com>2010-03-01 00:35:34 +0000
commitca57499b726a11ab2f59e4f90f5efe8a7a945b60 (patch)
treede2bdab63fa78803114ee1c0c32b6a3590745513 /Lib/test
parent9922a9a9cfc6dcc74ddf65d11acefa15e6a13ee6 (diff)
downloadcpython-git-ca57499b726a11ab2f59e4f90f5efe8a7a945b60.tar.gz
Merged revisions 78523 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r78523 | gregory.p.smith | 2010-02-28 16:05:08 -0800 (Sun, 28 Feb 2010) | 3 lines 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 99f31b984d..a9723b18f3 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
@@ -732,8 +733,27 @@ class ProcessTestCase(unittest.TestCase):
p.terminate()
self.assertNotEqual(p.wait(), 0)
+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():
- test_support.run_unittest(ProcessTestCase)
+ test_support.run_unittest(ProcessTestCase,
+ HelperFunctionTests)
if hasattr(test_support, "reap_children"):
test_support.reap_children()