Lines Matching refs: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)
349 mf = mmap.mmap(f.fileno(), 0, offset=65536, access=mmap.ACCESS_READ)
365 self.assertRaises(ValueError, mmap.mmap, f.fileno(), 0,
375 mf = mmap.mmap(f.fileno(), 10)
387 m = mmap.mmap(-1, len(data))
394 m = mmap.mmap(-1, 100)
409 m = mmap.mmap(-1, 1) # single byte
418 # anonymous mmap.mmap(-1, PAGE)
419 m = mmap.mmap(-1, PAGESIZE)
421 self.assertEqual(m[x], '\0', "anonymously mmap'ed contents should be zero")
430 m = mmap.mmap(-1, len(s))
444 m = mmap.mmap(-1, len(s))
467 return mmap.mmap (f.fileno(), 0)
474 m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
476 self.fail("should not have been able to mmap empty file")
478 self.assertEqual(e.message, "cannot mmap an empty file")
486 halfsize = mmap.ALLOCATIONGRANULARITY
496 m = mmap.mmap(f.fileno(), mapsize, offset=offset)
506 m = mmap.mmap(f.fileno(), mapsize - halfsize, offset=halfsize)
540 class anon_mmap(mmap.mmap):
542 return mmap.mmap.__new__(klass, -1, *args, **kwargs)
546 if not hasattr(mmap, 'PROT_READ'):
551 m = mmap.mmap(f.fileno(), mapsize, prot=mmap.PROT_READ)
556 self.assertTrue(issubclass(mmap.error, EnvironmentError))
557 self.assertIn("mmap.error", str(mmap.error))
563 m = mmap.mmap(f.fileno(), len(data))
598 m1 = mmap.mmap(-1, len(data1), tagname="foo")
600 m2 = mmap.mmap(-1, len(data2), tagname="foo")
608 m1 = mmap.mmap(-1, len(data1), tagname="foo")
610 m2 = mmap.mmap(-1, len(data2), tagname="boo")
619 m = mmap.mmap(-1, 1000, tagname="foo")
621 mmap.mmap(-1, 5000, tagname="foo")[:] # same tagname, but larger size
629 m = mmap.mmap(f.fileno(), 0)
647 with self.assertRaises(mmap.error):
648 m = mmap.mmap(s.fileno(), 10)
677 m = mmap.mmap(f.fileno(), 0, offset=0x140000000, access=mmap.ACCESS_READ)
689 mmap.mmap(f.fileno(), 0x180000000, access=mmap.ACCESS_READ)
691 mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
692 m = mmap.mmap(f.fileno(), 0x10000, access=mmap.ACCESS_READ)
698 # Issue 11277: mmap() with large (~4GB) sparse files crashes on OS X.
705 m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)