From 7249b479c168022f1080463839123567d5cfc7f1 Mon Sep 17 00:00:00 2001
From: Alberto Bertogli <albertito@blitiri.com.ar>
Date: Thu, 24 Sep 2009 22:42:19 -0300
Subject: [PATCH 06/15] tests/stress: Add an option to keep the file, and remove it by default

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
---
 tests/stress/jiostress |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/tests/stress/jiostress b/tests/stress/jiostress
index 542f98f..859168b 100755
--- a/tests/stress/jiostress
+++ b/tests/stress/jiostress
@@ -47,9 +47,13 @@ def randfloat(min, max):
 class ConsistencyError (Exception):
 	pass
 
-def jfsck(fname):
+def jfsck(fname, cleanup = False):
+	flags = 0
+	if cleanup:
+		flags = libjio.J_CLEANUP
+
 	try:
-		r = libjio.jfsck(fname)
+		r = libjio.jfsck(fname, flags = flags)
 		return r
 	except IOError as e:
 		if e.args[0] == libjio.J_ENOJOURNAL:
@@ -632,6 +636,9 @@ def main():
 	parser.add_option("", "--no-verify", dest = "do_verify",
 		action = "store_false", default = True,
 		help = "do not perform verifications")
+	parser.add_option("", "--keep", dest = "keep",
+		action = "store_true", default = False,
+		help = "keep the file after completing the test")
 
 	options, args = parser.parse_args()
 
@@ -665,7 +672,9 @@ def main():
 
 	r = jfsck(fname)
 	print("Final check completed")
-	#os.unlink(fname)
+	if not options.keep:
+		jfsck(fname, cleanup = True)
+		os.unlink(fname)
 
 
 if __name__ == '__main__':
-- 
1.6.2.2.646.gb214

