git » libjio » commit 87a9c51

tests/stress: Show information about the data when corruption is detected

author Alberto Bertogli
2009-07-15 18:55:31 UTC
committer Alberto Bertogli
2009-07-16 15:39:01 UTC
parent de5f21f9ebc9b437a94cdb85fb961ecc5cd2d1e4

tests/stress: Show information about the data when corruption is detected

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

tests/stress/jiostress +21 -0

diff --git a/tests/stress/jiostress b/tests/stress/jiostress
index 7ae2dc5..98a0c28 100755
--- a/tests/stress/jiostress
+++ b/tests/stress/jiostress
@@ -53,6 +53,21 @@ def jfsck(fname):
 		else:
 			raise
 
+def comp_cont(bytes):
+	"'aaaabbcc' -> [ ('a', 4), ('b', 2), ('c', 2) ]"
+	l = []
+	prev = bytes[0]
+	c = 1
+	for b in bytes[1:]:
+		if (b == prev):
+			c += 1
+			continue
+
+		l.append((prev, c))
+		prev = b
+		c = 1
+	return l
+
 
 #
 # The test itself
@@ -166,6 +181,12 @@ class Stresser:
 		real_data = self.pread(self.current_range[0],
 				self.current_range[1])
 		if real_data not in (self.prev_data, self.new_data):
+			print('Corruption detected')
+			print('Range:', self.current_range)
+			print('Real:', comp_cont(real_data))
+			print('Prev:', comp_cont(self.prev_data))
+			print('New: ', comp_cont(self.new_data))
+			print()
 			raise ConsistencyError
 
 	def reopen(self):