Merged revisions 88460,88464,88466,88486,88511,88652 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r88460 | antoine.pitrou | 2011-02-21 19:03:13 +0100 (lun., 21 févr. 2011) | 4 lines
Issue #10276: Fix the results of zlib.crc32() and zlib.adler32() on buffers
larger than 4GB. Patch by Nadeem Vawda.
........
r88464 | antoine.pitrou | 2011-02-21 20:05:08 +0100 (lun., 21 févr. 2011) | 3 lines
Fix issues on 32-bit systems introduced by r88460
........
r88466 | antoine.pitrou | 2011-02-21 20:28:40 +0100 (lun., 21 févr. 2011) | 3 lines
Fix compile error under MSVC introduced by r88460.
........
r88486 | antoine.pitrou | 2011-02-22 00:41:12 +0100 (mar., 22 févr. 2011) | 5 lines
Issue #4681: Allow mmap() to work on file sizes and offsets larger than
4GB, even on 32-bit builds. Initial patch by Ross Lagerwall, adapted for
32-bit Windows.
........
r88511 | antoine.pitrou | 2011-02-22 22:42:56 +0100 (mar., 22 févr. 2011) | 4 lines
Issue #11277: finally fix Snow Leopard crash following r88460.
(probably an OS-related issue with mmap)
........
r88652 | antoine.pitrou | 2011-02-26 16:58:05 +0100 (sam., 26 févr. 2011) | 4 lines
Issue #9931: Fix hangs in GUI tests under Windows in certain conditions.
Patch by Hirokazu Yamamoto.
........
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py
index 62569b9..d6addff 100644
--- a/Lib/test/test_mmap.py
+++ b/Lib/test/test_mmap.py
@@ -1,6 +1,6 @@
-from test.support import TESTFN, run_unittest, import_module
+from test.support import TESTFN, run_unittest, import_module, unlink, requires
import unittest
-import os, re, itertools, socket
+import os, re, itertools, socket, sys
# Skip test if we can't import mmap.
mmap = import_module('mmap')
@@ -636,8 +636,63 @@
finally:
s.close()
+
+class LargeMmapTests(unittest.TestCase):
+
+ def setUp(self):
+ unlink(TESTFN)
+
+ def tearDown(self):
+ unlink(TESTFN)
+
+ def _working_largefile(self):
+ # Only run if the current filesystem supports large files.
+ f = open(TESTFN, 'wb', buffering=0)
+ try:
+ f.seek(0x80000001)
+ f.write(b'x')
+ f.flush()
+ except (IOError, OverflowError):
+ raise unittest.SkipTest("filesystem does not have largefile support")
+ finally:
+ f.close()
+ unlink(TESTFN)
+
+ def test_large_offset(self):
+ if sys.platform[:3] == 'win' or sys.platform == 'darwin':
+ requires('largefile',
+ 'test requires %s bytes and a long time to run' % str(0x180000000))
+ self._working_largefile()
+ with open(TESTFN, 'wb') as f:
+ f.seek(0x14FFFFFFF)
+ f.write(b" ")
+
+ with open(TESTFN, 'rb') as f:
+ m = mmap.mmap(f.fileno(), 0, offset=0x140000000, access=mmap.ACCESS_READ)
+ try:
+ self.assertEqual(m[0xFFFFFFF], 32)
+ finally:
+ m.close()
+
+ def test_large_filesize(self):
+ if sys.platform[:3] == 'win' or sys.platform == 'darwin':
+ requires('largefile',
+ 'test requires %s bytes and a long time to run' % str(0x180000000))
+ self._working_largefile()
+ with open(TESTFN, 'wb') as f:
+ f.seek(0x17FFFFFFF)
+ f.write(b" ")
+
+ with open(TESTFN, 'rb') as f:
+ m = mmap.mmap(f.fileno(), 0x10000, access=mmap.ACCESS_READ)
+ try:
+ self.assertEqual(m.size(), 0x180000000)
+ finally:
+ m.close()
+
+
def test_main():
- run_unittest(MmapTests)
+ run_unittest(MmapTests, LargeMmapTests)
if __name__ == '__main__':
test_main()