git » libjio » commit ed84572

tests/stress: Wrap around jfsck()

author Alberto Bertogli
2009-07-15 18:54:15 UTC
committer Alberto Bertogli
2009-07-15 18:56:10 UTC
parent a6530728475a07aebc313728e42726babbc3cef3

tests/stress: Wrap around jfsck()

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

tests/stress/jiostress +13 -9

diff --git a/tests/stress/jiostress b/tests/stress/jiostress
index 83973cb..dc0e2a7 100755
--- a/tests/stress/jiostress
+++ b/tests/stress/jiostress
@@ -43,6 +43,16 @@ def randfloat(min, max):
 class ConsistencyError (Exception):
 	pass
 
+def jfsck(fname):
+	try:
+		r = libjio.jfsck(fname)
+		return r
+	except IOError as e:
+		if e.args[0] == libjio.J_ENOJOURNAL:
+			return { 'total': 0 }
+		else:
+			raise
+
 
 #
 # The test itself
@@ -151,14 +161,8 @@ class Stresser:
 
 	def reopen(self):
 		self.jf = None
-		r = { 'total': 0 }
-		try:
-			r = libjio.jfsck(self.fname)
-		except IOError as e:
-			if e.args[0] == libjio.J_ENOJOURNAL:
-				pass
-			else:
-				raise
+		r = jfsck(self.fname)
+
 		self.verify()
 
 		self.jf = libjio.open(self.fname,
@@ -265,7 +269,7 @@ def main():
 	print("  %d operations" % nops)
 	print("  %d simulated failures" % nfailures)
 
-	r = libjio.jfsck(fname)
+	r = jfsck(fname)
 	assert r['total'] == 0
 	print("Final check completed")
 	#os.unlink(fname)