Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools tests shell base_probe: Enhance print_overall_results to print summary information

Currently print_overall_results prints the number of fails in the
summary, example from base_probe tests in testsuite_probe:

## [ FAIL ] ## perf_probe :: test_invalid_options SUMMARY ::
11 failures found

test_invalid_options contains multiple tests and out of that 11 failed.
Sometimes it could happen that it is due to missing dependency in the
build or environment dependency.

Example, perf probe -L requires DWARF enabled. otherwise
it fails as below:

./perf probe -L
Error: switch `L' is not available because NO_DWARF=1

"-L" is tested as one of the option in:

for opt in '-a' '-d' '-L' '-V'; do
<<perf probe test>>
print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "missing argument
for $opt"

Here -a and -d doesn't require DWARF. Similarly there are few other
tests requiring DWARF.

To hint the user that missing DWARF could be one issue, update
print_overall_results to print a comment string along with summary
hinting the possible cause. Update test_invalid_options.sh and
test_line_semantics.sh to pass the info about DWARF requirement since
these tests failed when perf is built without DWARF.

Use the check for presence of DWARF with "perf check feature" and append
the hint message based on the result.

With the change:

## [ FAIL ] ## perf_probe :: test_invalid_options SUMMARY ::
11 failures found :: Some of the tests need DWARF to run

Reviewed-by: Kajol Jain <kjain@linux.ibm.com>
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Disha Goel <disgoel@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Veronika Molnarova <vmolnaro@redhat.com>
Cc: linuxppc-dev@lists.ozlabs.org
Link: https://lore.kernel.org/r/20241206135254.35727-1-atrajeev@linux.vnet.ibm.com
[ Minor edits changing "dwarf" to "DWARF" as its an acronym ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Athira Rajeev and committed by
Arnaldo Carvalho de Melo
ea3683fd 2aad2130

+12 -3
+4 -1
tools/perf/tests/shell/base_probe/test_invalid_options.sh
··· 22 22 exit 0 23 23 fi 24 24 25 + # Check for presence of DWARF 26 + $CMD_PERF check feature -q dwarf 27 + [ $? -ne 0 ] && HINT_FAIL="Some of the tests need DWARF to run" 25 28 26 29 ### missing argument 27 30 ··· 78 75 79 76 80 77 # print overall results 81 - print_overall_results "$TEST_RESULT" 78 + print_overall_results "$TEST_RESULT" $HINT_FAIL 82 79 exit $?
+4 -1
tools/perf/tests/shell/base_probe/test_line_semantics.sh
··· 23 23 exit 0 24 24 fi 25 25 26 + # Check for presence of DWARF 27 + $CMD_PERF check feature -q dwarf 28 + [ $? -ne 0 ] && HINT_FAIL="Some of the tests need DWARF to run" 26 29 27 30 ### acceptable --line descriptions 28 31 ··· 54 51 55 52 56 53 # print overall results 57 - print_overall_results "$TEST_RESULT" 54 + print_overall_results "$TEST_RESULT" $HINT_FAIL 58 55 exit $?
+4 -1
tools/perf/tests/shell/common/init.sh
··· 46 46 print_overall_results() 47 47 { 48 48 RETVAL="$1"; shift 49 + TASK_COMMENT="$*" 50 + test -n "$TASK_COMMENT" && TASK_COMMENT=":: $TASK_COMMENT" 51 + 49 52 if [ $RETVAL -eq 0 ]; then 50 53 _echo "$MALLPASS## [ PASS ] ##$MEND $TEST_NAME :: $THIS_TEST_NAME SUMMARY" 51 54 else 52 - _echo "$MALLFAIL## [ FAIL ] ##$MEND $TEST_NAME :: $THIS_TEST_NAME SUMMARY :: $RETVAL failures found" 55 + _echo "$MALLFAIL## [ FAIL ] ##$MEND $TEST_NAME :: $THIS_TEST_NAME SUMMARY :: $RETVAL failures found $TASK_COMMENT" 53 56 fi 54 57 return $RETVAL 55 58 }