[CRIU] [PATCH] zdtm: print 5 lines before an error

Andrei Vagin avagin at openvz.org
Wed Mar 29 00:03:05 PDT 2017


From: Andrei Vagin <avagin at virtuozzo.com>

It's very hard to understand an error without a context

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 test/zdtm.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/test/zdtm.py b/test/zdtm.py
index bd82a60..d35731b 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -1617,13 +1617,19 @@ def print_error(line):
 def grep_errors(fname):
 	first = True
 	print_next = False
+	before = []
 	for l in open(fname):
+		before.append(l)
+		if len(before) > 5:
+			before.pop(0)
 		if "Error" in l:
 			if first:
 				print_fname(fname, 'log')
 				print_sep("grep Error", "-", 60)
 				first = False
-			print_next = print_error(l)
+			for i in before:
+				print_next = print_error(i)
+			before = []
 		else:
 			if print_next:
 				print_next = print_error(l)
-- 
2.7.4



More information about the CRIU mailing list