[RFC][PATCH] ftracetest: Fix hist unsupported result in hist selftests
From: Steven Rostedt
Date: Mon May 23 2016 - 15:15:46 EST
[ Folks, is this a proper work around? ]
When histograms are not configured in the kernel, the ftracetest histogram
selftests should return "unsupported" and not "Failed". To detect this, the
test scripts have:
FEATURE=`grep hist events/sched/sched_process_fork/trigger`
if [ -z "$FEATURE" ]; then
echo "hist trigger is not supported"
exit_unsupported
fi
The problem is that '-e' is in effect and any error will cause the program
to terminate. The grep for 'hist' fails, because it is not compiled it (thus
unsupported), but because grep has an error code for failing to find the
string, it causes the program to terminate, and is marked as a failed test.
As a work around, I added "|| echo -n ''" to not let bash terminate the
script on a failed grep, and then the rest of the script can handle the fact
that histograms are not supported and return a proper result.
Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
---
tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc | 2 +-
tools/testing/selftests/ftrace/test.d/trigger/trigger-hist.tc | 2 +-
tools/testing/selftests/ftrace/test.d/trigger/trigger-multihist.tc | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc
index c2b61c4fda11..6c100759c758 100644
--- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc
+++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc
@@ -26,7 +26,7 @@ fi
reset_tracer
do_reset
-FEATURE=`grep hist events/sched/sched_process_fork/trigger`
+FEATURE=`grep hist events/sched/sched_process_fork/trigger || echo -n ''`
if [ -z "$FEATURE" ]; then
echo "hist trigger is not supported"
exit_unsupported
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist.tc
index b2902d42a537..8d691dc0c5cc 100644
--- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist.tc
+++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist.tc
@@ -26,7 +26,7 @@ fi
reset_tracer
do_reset
-FEATURE=`grep hist events/sched/sched_process_fork/trigger`
+FEATURE=`grep hist events/sched/sched_process_fork/trigger || echo -n ''`
if [ -z "$FEATURE" ]; then
echo "hist trigger is not supported"
exit_unsupported
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-multihist.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-multihist.tc
index 03c4a46561fc..1a11e641e97d 100644
--- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-multihist.tc
+++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-multihist.tc
@@ -26,7 +26,7 @@ fi
reset_tracer
do_reset
-FEATURE=`grep hist events/sched/sched_process_fork/trigger`
+FEATURE=`grep hist events/sched/sched_process_fork/trigger || echo -n ''`
if [ -z "$FEATURE" ]; then
echo "hist trigger is not supported"
exit_unsupported
--
1.8.3.1