diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-01-28 17:56:40 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-01-28 17:56:40 (GMT) |
commit | b49a1edc1556d99a9231f0e7da54e01096f4d912 (patch) | |
tree | 24067c21aace36e35cbcc5297ea82f0cf3d60459 /Lib | |
parent | c8241fdde7bce66f74363f8240e1b29d75fab3f8 (diff) | |
parent | 8f475effbc860e84e266923f9c19915914cc780f (diff) | |
download | cpython-b49a1edc1556d99a9231f0e7da54e01096f4d912.zip cpython-b49a1edc1556d99a9231f0e7da54e01096f4d912.tar.gz cpython-b49a1edc1556d99a9231f0e7da54e01096f4d912.tar.bz2 |
Merge heads
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/ctypes/test/test_arrays.py | 12 | ||||
-rw-r--r-- | Lib/ctypes/test/test_pointers.py | 9 | ||||
-rw-r--r-- | Lib/test/eintrdata/eintr_tester.py | 22 | ||||
-rw-r--r-- | Lib/test/test_sysconfig.py | 3 |
4 files changed, 35 insertions, 11 deletions
diff --git a/Lib/ctypes/test/test_arrays.py b/Lib/ctypes/test/test_arrays.py index 8ca77e0..4ed566b 100644 --- a/Lib/ctypes/test/test_arrays.py +++ b/Lib/ctypes/test/test_arrays.py @@ -24,20 +24,24 @@ class ArrayTestCase(unittest.TestCase): self.assertEqual(len(ia), alen) # slot values ok? - values = [ia[i] for i in range(len(init))] + values = [ia[i] for i in range(alen)] self.assertEqual(values, init) + # out-of-bounds accesses should be caught + with self.assertRaises(IndexError): ia[alen] + with self.assertRaises(IndexError): ia[-alen-1] + # change the items from operator import setitem new_values = list(range(42, 42+alen)) [setitem(ia, n, new_values[n]) for n in range(alen)] - values = [ia[i] for i in range(len(init))] + values = [ia[i] for i in range(alen)] self.assertEqual(values, new_values) # are the items initialized to 0? ia = int_array() - values = [ia[i] for i in range(len(init))] - self.assertEqual(values, [0] * len(init)) + values = [ia[i] for i in range(alen)] + self.assertEqual(values, [0] * alen) # Too many initializers should be caught self.assertRaises(IndexError, int_array, *range(alen*2)) diff --git a/Lib/ctypes/test/test_pointers.py b/Lib/ctypes/test/test_pointers.py index 225b9d1..751f85f 100644 --- a/Lib/ctypes/test/test_pointers.py +++ b/Lib/ctypes/test/test_pointers.py @@ -56,9 +56,13 @@ class PointersTestCase(unittest.TestCase): # C code: # int x = 12321; # res = &x - res.contents = c_int(12321) + x = c_int(12321) + res.contents = x self.assertEqual(i.value, 54345) + x.value = -99 + self.assertEqual(res.contents.value, -99) + def test_callbacks_with_pointers(self): # a function type receiving a pointer PROTOTYPE = CFUNCTYPE(c_int, POINTER(c_int)) @@ -131,9 +135,10 @@ class PointersTestCase(unittest.TestCase): def test_basic(self): p = pointer(c_int(42)) - # Although a pointer can be indexed, it ha no length + # Although a pointer can be indexed, it has no length self.assertRaises(TypeError, len, p) self.assertEqual(p[0], 42) + self.assertEqual(p[0:1], [42]) self.assertEqual(p.contents.value, 42) def test_charpp(self): diff --git a/Lib/test/eintrdata/eintr_tester.py b/Lib/test/eintrdata/eintr_tester.py index e3c36f9..9931a55 100644 --- a/Lib/test/eintrdata/eintr_tester.py +++ b/Lib/test/eintrdata/eintr_tester.py @@ -334,10 +334,12 @@ class SocketEINTRTest(EINTRBaseTest): self._test_open("fp = open(path, 'r')\nfp.close()", self.python_open) + @unittest.skipIf(sys.platform == 'darwin', "hangs under OS X; see issue #25234") def os_open(self, path): fd = os.open(path, os.O_WRONLY) os.close(fd) + @unittest.skipIf(sys.platform == "darwin", "hangs under OS X; see issue #25234") def test_os_open(self): self._test_open("fd = os.open(path, os.O_RDONLY)\nos.close(fd)", self.os_open) @@ -370,10 +372,10 @@ class SignalEINTRTest(EINTRBaseTest): @unittest.skipUnless(hasattr(signal, 'sigwaitinfo'), 'need signal.sigwaitinfo()') def test_sigwaitinfo(self): - # Issue #25277: The sleep is a weak synchronization between the parent - # and the child process. If the sleep is too low, the test hangs on - # slow or highly loaded systems. - self.sleep_time = 2.0 + # Issue #25277, #25868: give a few miliseconds to the parent process + # between os.write() and signal.sigwaitinfo() to works around a race + # condition + self.sleep_time = 0.100 signum = signal.SIGUSR1 pid = os.getpid() @@ -381,18 +383,28 @@ class SignalEINTRTest(EINTRBaseTest): old_handler = signal.signal(signum, lambda *args: None) self.addCleanup(signal.signal, signum, old_handler) + rpipe, wpipe = os.pipe() + code = '\n'.join(( 'import os, time', 'pid = %s' % os.getpid(), 'signum = %s' % int(signum), 'sleep_time = %r' % self.sleep_time, + 'rpipe = %r' % rpipe, + 'os.read(rpipe, 1)', + 'os.close(rpipe)', 'time.sleep(sleep_time)', 'os.kill(pid, signum)', )) t0 = time.monotonic() - proc = self.subprocess(code) + proc = self.subprocess(code, pass_fds=(rpipe,)) + os.close(rpipe) with kill_on_error(proc): + # sync child-parent + os.write(wpipe, b'x') + os.close(wpipe) + # parent signal.sigwaitinfo([signum]) dt = time.monotonic() - t0 diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index 0917c3e..a23bf06a 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -421,6 +421,8 @@ class MakefileTests(unittest.TestCase): print("var3=42", file=makefile) print("var4=$/invalid", file=makefile) print("var5=dollar$$5", file=makefile) + print("var6=${var3}/lib/python3.5/config-$(VAR2)$(var5)" + "-x86_64-linux-gnu", file=makefile) vars = sysconfig._parse_makefile(TESTFN) self.assertEqual(vars, { 'var1': 'ab42', @@ -428,6 +430,7 @@ class MakefileTests(unittest.TestCase): 'var3': 42, 'var4': '$/invalid', 'var5': 'dollar$5', + 'var6': '42/lib/python3.5/config-b42dollar$5-x86_64-linux-gnu', }) |