From 87a9c519df00c3ec700825ed0bdb3a8e6098898e Mon Sep 17 00:00:00 2001
From: Alberto Bertogli <albertito@blitiri.com.ar>
Date: Wed, 15 Jul 2009 15:55:31 -0300
Subject: [PATCH 42/74] tests/stress: Show information about the data when corruption is detected

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

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):
-- 
1.6.2.2.646.gb214

