]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
fuse/runtests: make exceptions in 'read_in_random_order' into TestFailures
authorrobk-tahoe <robk-tahoe@allmydata.com>
Mon, 20 Oct 2008 23:52:35 +0000 (16:52 -0700)
committerrobk-tahoe <robk-tahoe@allmydata.com>
Mon, 20 Oct 2008 23:52:35 +0000 (16:52 -0700)
contrib/fuse/runtests.py

index 67f68091e083672f0598bf40ac7b59b1d7541077..5a94cce832cbaea1189e26f70bc44ffd96aab8fb 100644 (file)
@@ -468,19 +468,27 @@ class SystemTest (object):
         # 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
         path = os.path.join(testdir, name)
-        fsize = os.path.getsize(path)
-        if fsize != len(body):
-            tmpl = 'Expected file size %s but found %s'
-            raise TestFailure(tmpl, len(body), fsize)
-
-        f = open(path, 'r')
-        posns = range(0,sz,bs)
-        random.shuffle(posns)
-        data = [None] * (sz/bs)
-        for p in posns:
-            f.seek(p)
-            data[p/bs] = f.read(bs)
-        found = ''.join(data)
+        try:
+            fsize = os.path.getsize(path)
+            if fsize != len(body):
+                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)
+
+        try:
+            f = open(path, 'r')
+            posns = range(0,sz,bs)
+            random.shuffle(posns)
+            data = [None] * (sz/bs)
+            for p in posns:
+                f.seek(p)
+                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:
             tmpl = 'Expected file contents %s but found %s'