Commit 677ebcb1 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 11f0976e
......@@ -495,9 +495,13 @@ class tFile:
if not isinstance(dataok, bytes):
dataok = dataok.encode('utf-8')
assert len(dataok) <= t.blksize
blkdata, blkrev = t.tdb._blkDataAt(t.zf, blk, t.at)
blkdata, _ = t.tdb._blkDataAt(t.zf, blk, t.at)
assert blkdata == dataok, "computed vs explicit data"
t._assertBlk(blk, dataok, pinokByWLink)
@func
def _assertBlk(t, blk, dataok, pinokByWLink=None, pinfunc=None):
assert len(dataok) <= t.blksize
dataok += b'\0'*(t.blksize - len(dataok)) # tailing zeros
assert blk < t._sizeinblk()
......@@ -516,6 +520,7 @@ class tFile:
# watches that must be notified if access goes to @head/file
wpin = {} # tWatchLink -> pinok
blkrev = t.tdb._blkRevAt(t.zf, blk, t.at)
if t.at is None: # @head/...
for wlink in t.tdb._wlinks:
pinok = {}
......@@ -570,7 +575,7 @@ class tFile:
b = _rx
ev.append('read ' + b)
ev = doCheckingPin(_, pinokByWLink)
ev = doCheckingPin(_, pinokByWLink, pinfunc)
# XXX hack - wlinks are notified and emit events simultaneously - we
# check only that events begin and end with read pre/post and that pins
......@@ -589,7 +594,7 @@ class tFile:
# verify full data of the block
# XXX assert individually for every block's page? (easier debugging?)
assert blkview == dataok
assert blkview.tobytes() == dataok
# we just accessed the block in full - it has to be in OS cache completely
assert t.cached()[blk] == 1
......@@ -1386,7 +1391,7 @@ def test_wcfs_watch_setup():
# verify that already setup watch(es) receive correct pins on block access.
@func
def test_wcfs_watch_vs_commit(): # XXX commit -> access ?
def test_wcfs_watch_vs_access():
t = tDB(); zf = t.zfile; at0=t.at0
defer(t.close)
......@@ -1503,14 +1508,41 @@ def test_wcfs_watch_vs_commit(): # XXX commit -> access ?
wl3.close()
# verify that on pin message, while under pagefault, we can mmap @at/f[blk]
# into where head/f[blk] was mmaped.
@func
def test_wcfs_remmap_on_pin():
t = tDB(); zf = t.zfile
defer(t.close)
at1 = t.commit(zf, {2:'hello'})
at2 = t.commit(zf, {2:'world'})
f = t.open(zf)
f1 = t.open(zf, at=at1)
wl = t.openwatch()
wl.watch(zf, at1, {})
f.assertCache([0,0,0])
def _(wlink, foid, blk, at):
assert wlink is wl
assert foid == zf._p_oid
assert blk == 2
assert at == at1
mm.map_into_ro(f._blk(blk), f1.f.fileno(), blk*f.blksize)
f._assertBlk(2, 'hello', {wl: {2:at1}}, pinfunc=_) # NOTE not world
# XXX drop file[blk] from cache, access again -> no pin message sent the second time
# XXX watch with @at > head - must wait for head to become >= at
# XXX no reply to pin - killed
# XXX mmap f; remmap f[blk] on pin message while under pagefault - should get changed page
# XXX watch @at when file did not existed -> error
......
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