Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(98491)

Side by Side Diff: Lib/test/test_mmap.py

Issue 23670: Modifications to support iOS as a development platform
Patch Set: Created 3 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_marshal.py ('k') | Lib/test/test_os.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 from test.support import (TESTFN, run_unittest, import_module, unlink, 1 from test.support import (TESTFN, run_unittest, import_module, unlink,
2 requires, _2G, _4G, gc_collect, cpython_only) 2 requires, _2G, _4G, gc_collect, cpython_only)
3 import unittest 3 import unittest
4 import os 4 import os
5 import re 5 import re
6 import itertools 6 import itertools
7 import socket 7 import socket
8 import sys 8 import sys
9 import weakref 9 import weakref
10 10
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 self.assertEqual(fp.read(), b'c'*mapsize, 222 self.assertEqual(fp.read(), b'c'*mapsize,
223 "Copy-on-write test data file should not be mod ified.") 223 "Copy-on-write test data file should not be mod ified.")
224 # Ensuring copy-on-write maps cannot be resized 224 # Ensuring copy-on-write maps cannot be resized
225 self.assertRaises(TypeError, m.resize, 2*mapsize) 225 self.assertRaises(TypeError, m.resize, 2*mapsize)
226 m.close() 226 m.close()
227 227
228 # Ensuring invalid access parameter raises exception 228 # Ensuring invalid access parameter raises exception
229 with open(TESTFN, "r+b") as f: 229 with open(TESTFN, "r+b") as f:
230 self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize, access =4) 230 self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize, access =4)
231 231
232 if os.name == "posix": 232 if os.name == "posix" and sys.platform != 'ios':
233 # Try incompatible flags, prot and access parameters. 233 # Try incompatible flags, prot and access parameters.
234 with open(TESTFN, "r+b") as f: 234 with open(TESTFN, "r+b") as f:
235 self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize, 235 self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize,
236 flags=mmap.MAP_PRIVATE, 236 flags=mmap.MAP_PRIVATE,
237 prot=mmap.PROT_READ, access=mmap.ACCESS_WRITE) 237 prot=mmap.PROT_READ, access=mmap.ACCESS_WRITE)
238 238
239 # Try writing with PROT_EXEC and without PROT_WRITE 239 # Try writing with PROT_EXEC and without PROT_WRITE
240 prot = mmap.PROT_READ | getattr(mmap, 'PROT_EXEC', 0) 240 prot = mmap.PROT_READ | getattr(mmap, 'PROT_EXEC', 0)
241 with open(TESTFN, "r+b") as f: 241 with open(TESTFN, "r+b") as f:
242 m = mmap.mmap(f.fileno(), mapsize, prot=prot) 242 m = mmap.mmap(f.fileno(), mapsize, prot=prot)
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 715
716 class LargeMmapTests(unittest.TestCase): 716 class LargeMmapTests(unittest.TestCase):
717 717
718 def setUp(self): 718 def setUp(self):
719 unlink(TESTFN) 719 unlink(TESTFN)
720 720
721 def tearDown(self): 721 def tearDown(self):
722 unlink(TESTFN) 722 unlink(TESTFN)
723 723
724 def _make_test_file(self, num_zeroes, tail): 724 def _make_test_file(self, num_zeroes, tail):
725 if sys.platform[:3] == 'win' or sys.platform == 'darwin': 725 if sys.platform[:3] == 'win' or sys.platform in ('darwin', 'ios'):
726 requires('largefile', 726 requires('largefile',
727 'test requires %s bytes and a long time to run' % str(0x18000000 0)) 727 'test requires %s bytes and a long time to run' % str(0x18000000 0))
728 f = open(TESTFN, 'w+b') 728 f = open(TESTFN, 'w+b')
729 try: 729 try:
730 f.seek(num_zeroes) 730 f.seek(num_zeroes)
731 f.write(tail) 731 f.write(tail)
732 f.flush() 732 f.flush()
733 except (OSError, OverflowError): 733 except (OSError, OverflowError):
734 try: 734 try:
735 f.close() 735 f.close()
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 @unittest.skipUnless(sys.maxsize > _4G, "test cannot run on 32-bit systems") 772 @unittest.skipUnless(sys.maxsize > _4G, "test cannot run on 32-bit systems")
773 def test_around_4GB(self): 773 def test_around_4GB(self):
774 self._test_around_boundary(_4G) 774 self._test_around_boundary(_4G)
775 775
776 776
777 def test_main(): 777 def test_main():
778 run_unittest(MmapTests, LargeMmapTests) 778 run_unittest(MmapTests, LargeMmapTests)
779 779
780 if __name__ == '__main__': 780 if __name__ == '__main__':
781 test_main() 781 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_marshal.py ('k') | Lib/test/test_os.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+