perf tests shell: Fix check for libtracevent support
authorAthira Rajeev <atrajeev@linux.vnet.ibm.com>
Wed, 1 Feb 2023 18:04:21 +0000 (23:34 +0530)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 2 Feb 2023 00:44:26 +0000 (21:44 -0300)
Test “Use vfs_getname probe to get syscall args filenames” fails in
environment with missing libtraceevent support as below:

  82: Use vfs_getname probe to get syscall args filenames             :
  --- start ---
  test child forked, pid 304726
  Recording open file:
  event syntax error: 'probe:vfs_getname*'
                       \___ unsupported tracepoint

  libtraceevent is necessary for tracepoint support
  Run 'perf list' for a list of valid events

   Usage: perf record [<options>] [<command>]
      or: perf record [<options>] -- <command> [<options>]

      -e, --event <event>   event selector. use 'perf list' to list available events
  test child finished with -1
  ---- end ----
  Use vfs_getname probe to get syscall args filenames: FAILED!

The environment has debuginfo but is missing the libtraceevent devel.

Hence perf is compiled without libtraceevent support.  The test tries to
add probe “probe:vfs_getname” and then uses it with “perf record”.  This
fails at function “parse_events_add_tracepoint" due to missing
libtraceevent.

Similarly "probe libc's inet_pton & backtrace it with ping" test slso
fails with same reason.

Add a function in 'perf test shell' library to check if perf record with
—dry-run reports any error on missing support for libtraceevent. Update
both the tests to use this new function “skip_no_probe_record_support”
before proceeding With using probe point via perf builtin record.

With the change,

  82: Use vfs_getname probe to get syscall args filenames             :
  --- start ---
  test child forked, pid 305014
  Recording open file:
  libtraceevent is necessary for tracepoint support
  test child finished with -2
  ---- end ----
  Use vfs_getname probe to get syscall args filenames: Skip

   81: probe libc's inet_pton & backtrace it with ping                 :
  --- start ---
  test child forked, pid 305036
  libtraceevent is necessary for tracepoint support
  test child finished with -2
  ---- end ----
  probe libc's inet_pton & backtrace it with ping: Skip

Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Disha Goel <disgoel@linux.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nageswara R Sastry <rnsastry@linux.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: kjain@linux.ibm.com,
Cc: linuxppc-dev@lists.ozlabs.org
Link: http://lore.kernel.org/r/20230201180421.59640-2-atrajeev@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/tests/shell/lib/probe_vfs_getname.sh
tools/perf/tests/shell/record+probe_libc_inet_pton.sh
tools/perf/tests/shell/record+script_probe_vfs_getname.sh

index ed0a3972c4c81e0a9e7628c2245530b2adb9a6d2..60c5e34f90c41b427ab61039089dce38b580c3a9 100644 (file)
@@ -22,3 +22,11 @@ skip_if_no_debuginfo() {
        add_probe_vfs_getname -v 2>&1 | grep -E -q "^(Failed to find the path for the kernel|Debuginfo-analysis is not supported)|(file has no debug information)" && return 2
        return 1
 }
+
+# check if perf is compiled with libtraceevent support
+skip_no_probe_record_support() {
+       if [ $had_vfs_getname -eq 1 ] ; then
+               perf record --dry-run -e $1 2>&1 | grep "libtraceevent is necessary for tracepoint support" && return 2
+               return 1
+       fi
+}
index 08cdd902d0cf029c0c9486c0fadf7b590c9f6de3..b4149b2db4c6d7164469b07bfbdd43e5b647b579 100755 (executable)
@@ -11,6 +11,7 @@
 # Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
 
 . $(dirname $0)/lib/probe.sh
+. $(dirname $0)/lib/probe_vfs_getname.sh
 
 libc=$(grep -w libc /proc/self/maps | head -1 | sed -r 's/.*[[:space:]](\/.*)/\1/g')
 nm -Dg $libc 2>/dev/null | fgrep -q inet_pton || exit 254
@@ -57,6 +58,11 @@ trace_libc_inet_pton_backtrace() {
 
        perf_data=`mktemp -u /tmp/perf.data.XXX`
        perf_script=`mktemp -u /tmp/perf.script.XXX`
+
+       # Check presence of libtraceevent support to run perf record
+       skip_no_probe_record_support "$event_name/$eventattr/"
+       [ $? -eq 2 ] && return 2
+
        perf record -e $event_name/$eventattr/ -o $perf_data ping -6 -c 1 ::1 > /dev/null 2>&1
        # check if perf data file got created in above step.
        if [ ! -e $perf_data ]; then
index 7f83b2715b9a5775278f120625b5abe22643b10c..1341437e1bd99bbbe16243c931bb8671457a4d89 100755 (executable)
@@ -17,6 +17,9 @@ skip_if_no_perf_probe || exit 2
 
 record_open_file() {
        echo "Recording open file:"
+       # Check presence of libtraceevent support to run perf record
+       skip_no_probe_record_support "probe:vfs_getname*"
+       [ $? -eq 2 ] && return 2
        perf record -o ${perfdata} -e probe:vfs_getname\* touch $file
 }