mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-05-31 06:41:10 +00:00
fuse/runtests: make exceptions in 'read_in_random_order' into TestFailures
This commit is contained in:
parent
f08d181764
commit
3fbfd9fce3
@ -468,19 +468,27 @@ class SystemTest (object):
|
|||||||
# XXX this should also do a test where sz%bs != 0, so that it correctly tests
|
# XXX this should also do a test where sz%bs != 0, so that it correctly tests
|
||||||
# the edge case where the last read is a 'short' block
|
# the edge case where the last read is a 'short' block
|
||||||
path = os.path.join(testdir, name)
|
path = os.path.join(testdir, name)
|
||||||
fsize = os.path.getsize(path)
|
try:
|
||||||
if fsize != len(body):
|
fsize = os.path.getsize(path)
|
||||||
tmpl = 'Expected file size %s but found %s'
|
if fsize != len(body):
|
||||||
raise TestFailure(tmpl, len(body), fsize)
|
tmpl = 'Expected file size %s but found %s'
|
||||||
|
raise TestFailure(tmpl, len(body), fsize)
|
||||||
|
except Exception, err:
|
||||||
|
tmpl = 'Could not read file size for %r: %r'
|
||||||
|
raise TestFailure(tmpl, path, err)
|
||||||
|
|
||||||
f = open(path, 'r')
|
try:
|
||||||
posns = range(0,sz,bs)
|
f = open(path, 'r')
|
||||||
random.shuffle(posns)
|
posns = range(0,sz,bs)
|
||||||
data = [None] * (sz/bs)
|
random.shuffle(posns)
|
||||||
for p in posns:
|
data = [None] * (sz/bs)
|
||||||
f.seek(p)
|
for p in posns:
|
||||||
data[p/bs] = f.read(bs)
|
f.seek(p)
|
||||||
found = ''.join(data)
|
data[p/bs] = f.read(bs)
|
||||||
|
found = ''.join(data)
|
||||||
|
except Exception, err:
|
||||||
|
tmpl = 'Could not read file %r: %r'
|
||||||
|
raise TestFailure(tmpl, path, err)
|
||||||
|
|
||||||
if found != body:
|
if found != body:
|
||||||
tmpl = 'Expected file contents %s but found %s'
|
tmpl = 'Expected file contents %s but found %s'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user