Lines Matching full:mmap
6 mmap = import_module('mmap')
8 PAGESIZE = mmap.PAGESIZE
23 # Test mmap module on Unix systems and Windows
25 # Create a file to be mmap'ed.
33 m = mmap.mmap(f.fileno(), 2 * PAGESIZE)
61 # Test doing a regular expression match in an mmap'ed file
64 self.fail('regex match on mmap failed!')
83 # Try to seek beyond end of mmap...
124 m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_READ)
127 # Ensuring that readonly mmap can't be slice assigned
135 # Ensuring that readonly mmap can't be item assigned
143 # Ensuring that readonly mmap can't be write() to
152 # Ensuring that readonly mmap can't be write_byte() to
161 # Ensuring that readonly mmap can't be resized
175 # Opening mmap with size too big
179 m = mmap.mmap(f.fileno(), mapsize+1)
186 self.fail("Opening mmap with size+1 should work on Windows.")
190 self.fail("Opening mmap with size+1 should raise ValueError.")
199 # Opening mmap with access=ACCESS_WRITE
201 m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_WRITE)
215 # Opening mmap with access=ACCESS_COPY
217 m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_COPY)
232 self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize, access=4)
238 self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize,
239 flags=mmap.MAP_PRIVATE,
240 prot=mmap.PROT_READ, access=mmap.ACCESS_WRITE)
244 prot = mmap.PROT_READ | getattr(mmap, 'PROT_EXEC', 0)
246 m = mmap.mmap(f.fileno(), mapsize, prot=prot)
253 self.assertRaises(mmap.error, mmap.mmap, -2, 4096)
264 m = mmap.mmap(f.fileno(), n)
281 m = mmap.mmap(f.fileno(), n)
299 m = mmap.mmap(f.fileno(), n)
318 mf = mmap.mmap(f.fileno(), 2**16, access=mmap.ACCESS_READ)
332 mf = mmap.mmap(f.fileno(), 0)
348 mf = mmap.mmap(f.fileno(), 0, offset=65536, access=mmap.ACCESS_READ)
362 self.assertRaises(ValueError, mmap.mmap, f.fileno(), 0,
372 mf = mmap.mmap(f.fileno(), 10)
384 m = mmap.mmap(-1, len(data))
391 m = mmap.mmap(-1, 100)
406 m = mmap.mmap(-1, 1) # single byte
415 # anonymous mmap.mmap(-1, PAGE)
416 m = mmap.mmap(-1, PAGESIZE)
418 self.assertEqual(m[x], '\0', "anonymously mmap'ed contents should be zero")
427 m = mmap.mmap(-1, len(s))
441 m = mmap.mmap(-1, len(s))
464 return mmap.mmap (f.fileno(), 0)
471 "cannot mmap an empty file",
472 mmap.mmap, f.fileno(), 0,
473 access=mmap.ACCESS_READ)
479 halfsize = mmap.ALLOCATIONGRANULARITY
489 m = mmap.mmap(f.fileno(), mapsize, offset=offset)
499 m = mmap.mmap(f.fileno(), mapsize - halfsize, offset=halfsize)
533 class anon_mmap(mmap.mmap):
535 return mmap.mmap.__new__(klass, -1, *args, **kwargs)
538 @unittest.skipUnless(hasattr(mmap, 'PROT_READ'), "needs mmap.PROT_READ")
543 m = mmap.mmap(f.fileno(), mapsize, prot=mmap.PROT_READ)
548 self.assertTrue(issubclass(mmap.error, EnvironmentError))
549 self.assertIn("mmap.error", str(mmap.error))
555 m = mmap.mmap(f.fileno(), len(data))
590 m1 = mmap.mmap(-1, len(data1), tagname="foo")
592 m2 = mmap.mmap(-1, len(data2), tagname="foo")
600 m1 = mmap.mmap(-1, len(data1), tagname="foo")
602 m2 = mmap.mmap(-1, len(data2), tagname="boo")
612 m1 = mmap.mmap(-1, 100)
614 m2 = mmap.mmap(-1, 100, tagname=tagname)
621 m = mmap.mmap(-1, 1000, tagname="foo")
623 mmap.mmap(-1, 5000, tagname="foo")[:] # same tagname, but larger size
631 m = mmap.mmap(f.fileno(), 0)
650 with self.assertRaises(mmap.error):
651 m = mmap.mmap(s.fileno(), 10)
657 m = mmap.mmap(-1, 8192)
694 m = mmap.mmap(f.fileno(), 0, offset=0x140000000, access=mmap.ACCESS_READ)
706 mmap.mmap(f.fileno(), 0x180000000, access=mmap.ACCESS_READ)
708 mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
709 m = mmap.mmap(f.fileno(), 0x10000, access=mmap.ACCESS_READ)
715 # Issue 11277: mmap() with large (~4GB) sparse files crashes on OS X.
722 m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)