Commit d87991ec authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 6f4f0296
......@@ -1692,7 +1692,31 @@ def test_wcfs_watch_2files():
# ---- wcfs.py + virtmem integration ----
# XXX text ...
# tMapping provides testing environment for Mapping.
class tMapping(object):
def __init__(t, mmap):
t.mmap = mmap
# XXX assertCache
# assertBlk asserts that mmap[·] with · corresponding to blk has reads as dataok.
# see also: tFile.assertBlk .
def assertBlk(t, blk, dataok):
assert t.mmap.blk_start <= blk < t.mmap.blk_stop
blk_inmmap = blk - t.mmap.blk_start
if not isinstance(dataok, bytes):
dataok = dataok.encode('utf-8')
f = t.mmap.file
assert len(dataok) <= f.blksize
dataok += b'\0'*(f.blksize - len(dataok)) # trailing zeros
blkview = memoryview(t.mmap.mem[blk_inmmap*f.blksize:][:f.blksize])
assert blkview.tobytes() == dataok
# XXX assertData
# test_wcfspy_virtmem verifies wcfs.py integration with virtmem.
@func
def test_wcfspy_virtmem():
t = tDB(); zf = t.zfile
......@@ -1711,6 +1735,21 @@ def test_wcfspy_virtmem():
assert m1.blk_stop == 5
assert len(m1.mem) == 3*zf.blksize
f = m1.file
t1 = tMapping(m1)
#assertCache(m1, [0,0,0])
assert f.pinned == {}
t1.assertBlk(2, 'c1')
assert f.pinned == {2:at1}
t1.assertBlk(3, 'd1')
assert f.pinned == {2:at1}
t1.assertBlk(3, 'x')
assert f.pinned == {2:at1}
#assertData (m1, ['c1','d1',''])
# ---- misc ---
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment