Skip to contentSkip to conversation

perf test: Align the 'Ok'/'FAILED!' test results

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Oct 25, 2012 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  9a8e85ad0b61ec0720df7d24392163c2a12626d0
Gitweb:     http://git.kernel.org/tip/9a8e85ad0b61ec0720df7d24392163c2a12626d0
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Wed, 24 Oct 2012 15:44:41 -0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 24 Oct 2012 15:44:41 -0200

perf test: Align the 'Ok'/'FAILED!' test results

And also print 'FAILED!' in red.

Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/builtin-test.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
tools/perf/builtin-test.c +16 -2
index e2d9872d..a04276e 100644
@@ -6,6 +6,7 @@
 #include "builtin.h"
 
 #include "util/cache.h"
+#include "util/color.h"
 #include "util/debug.h"
 #include "util/debugfs.h"
 #include "util/evlist.h"
@@ -1485,18 +1486,31 @@ static bool perf_test__matches(int curr, int argc, const char *argv[])
 static int __cmd_test(int argc, const char *argv[])
 {
 	int i = 0;
+	int width = 0;
 
 	while (tests[i].func) {
+		int len = strlen(tests[i].desc);
+
+		if (width < len)
+			width = len;
+		++i;
+	}
+		
+	i = 0;
+	while (tests[i].func) {
 		int curr = i++, err;
 
 		if (!perf_test__matches(curr, argc, argv))
 			continue;
 
-		pr_info("%2d: %s:", i, tests[curr].desc);
+		pr_info("%2d: %-*s:", i, width, tests[curr].desc);
 		pr_debug("\n--- start ---\n");
 		err = tests[curr].func();
 		pr_debug("---- end ----\n%s:", tests[curr].desc);
-		pr_info(" %s\n", err ? "FAILED!\n" : "Ok");
+		if (err)
+			color_fprintf(stderr, PERF_COLOR_RED, " FAILED!\n");
+		else
+			pr_info(" Ok\n");
 	}
 
 	return 0;