Commit bd24d52e authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 61b173c9
......@@ -95,6 +95,10 @@ fi
# init part spawned from under setsid.
# $0 .qinit2 <command> ...
if [ "$1" == .qinit2 ]; then
# initialize terminal. In particular this has the effect to restore
# line wrapping for xterm, as kernel, initially assuming it has "linux"
# type terminal, somehow messes xterm settings.
command -v tput >/dev/null && tput init
# resize terminal to current host's xterm
command -v resize >/dev/null && eval `resize`
......
......@@ -517,21 +517,21 @@ class tWatch:
# expectPin asserts that wcfs sends expected pin messages.
#
# expectv is [] of (zf, blk, at)
# expect is {} blk -> at
# returns [] of received pin requests.
#
# XXX cancel waiting upon receiving "ok" from wcfs (-> error that missed pins were not received)
# XXX abort on timeout?
def expectPin(t, ctx, expectv):
def expectPin(t, ctx, zf, expect):
expected = set() # of expected pin messages
for zf, blk, at in expectv:
for blk, at in expect:
msg = b"pin %s #%d @%s" % (h(zf._p_oid), blk, h(at))
assert msg not in expected
expected.add(msg)
reqv = [] # of received requests
while len(expected) > 0:
req = t.recvReq(ctx)
try:
req = t.recvReq(ctx)
except Exception as e:
raise RuntimeError("%s\nnot all pin missages received - pending:\n%s" % (e, expected))
assert req is not None # channel not closed
assert req.msg in expected
expected.remove(req.msg)
......@@ -653,8 +653,7 @@ def test_wcfs():
wg = sync.WorkGroup(ctx)
def _(ctx):
pinv = w.expectPin(ctx, [(zf, 2, at1), (zf, 3, at0)])
#pinv = w.expectPin(ctx, {zf: [(2, at1), (3, at0)]}) XXX <- this way better? (sugar)
pinv = w.expectPin(ctx, zf, {2: at1, 3: at0})
for p in pinv:
p.reply(b"ack")
wg.go(_)
......@@ -664,21 +663,39 @@ def test_wcfs():
wg.wait()
print('\nCCC\n')
bg = context.background()
"""
# checkSetupWatch verifies setting up new watch for zf@at.
def checkSetupWatch(zf, at):
print('check setup watch f<%s> @%s' % (h(zf._p_oid), h(at)))
# all changes to zf
vdf = [_.byfile[zf] for _ in t.dFtail if zf in t.dFtail.byfile]
# changes to zf after at
vdfpost = [_ for _ in vdf if _.rev > at]
# open watch and check that we receive pins for blocks changed > at
# XXX ...
# open watch, send watch request and check that we receive pins for
# in-cache blocks changed > at.
w = t.openwatch()
ctx, cancel = context.with_cancel(bg)
wg = sync.WorkGroup(ctx)
def _(ctx):
pinv = w.expectPin(ctx, zf, {}) # XXX expect=?
for p in pinv:
p.reply(b"ack")
wg.go(_)
assert w.sendReq(ctx, b"watch %s @%s" % (h(zf._p_oid), h(at))) == "ok"
# cancel expectPin waiting upon receiving "ok" from wcfs
# -> error that missed pins were not received.
cancel()
wg.wait()
for i in range(len(t.dFtail)):
"""
1/0
return
......
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