perf test shell: Check if 'perf probe' is available, skip tests if not
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 14 Aug 2017 17:26:09 +0000 (14:26 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 15 Aug 2017 13:54:25 +0000 (10:54 -0300)
Add a library function that checks if 'perf probe' is built into the
tool being tested, skipping tests that need it.

Testing it on a system after removing the library needed to build
'probe' as a perf subcommand:

  # perf test ping vfs_getname
  59: Use vfs_getname probe to get syscall args filenames   : Skip
  60: probe libc's inet_pton & backtrace it with ping       : Skip
  61: Check open filename arg using perf trace + vfs_getname: Skip
  62: Add vfs_getname probe to get syscall args filenames   : Skip
  # perf probe
  perf: 'probe' is not a perf-command. See 'perf --help'.
  #

Now reinstalling elfutils-libelf-devel on this Fedora 26 system to
rebuild perf and then retest this:

  # perf test ping vfs_getname
  60: Use vfs_getname probe to get syscall args filenames   : Ok
  61: probe libc's inet_pton & backtrace it with ping       : Ok
  62: Check open filename arg using perf trace + vfs_getname: Ok
  63: Add vfs_getname probe to get syscall args filenames   : Ok
  #

Reported-by: Kim Phillips <kim.phillips@arm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-ctdck2gzsskqhjzu3ebb62zm@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/tests/shell/lib/probe.sh [new file with mode: 0644]
tools/perf/tests/shell/lib/probe_vfs_getname.sh
tools/perf/tests/shell/probe_vfs_getname.sh
tools/perf/tests/shell/record+script_probe_vfs_getname.sh
tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
tools/perf/tests/shell/trace+probe_vfs_getname.sh

diff --git a/tools/perf/tests/shell/lib/probe.sh b/tools/perf/tests/shell/lib/probe.sh
new file mode 100644 (file)
index 0000000..61da3b2
--- /dev/null
@@ -0,0 +1,6 @@
+# Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
+
+skip_if_no_perf_probe() {
+       perf probe |& grep -q 'is not a perf-command' && return 2
+       return 0
+}
index 3eaddf190a302a37e488bceb7ce358a025bfb089..46c1bb7076003b87974d6540303b8d7df0436d31 100644 (file)
@@ -1,6 +1,6 @@
 # Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
 
-perf probe -l | grep -q probe:vfs_getname
+perf probe -l |& grep -q probe:vfs_getname
 had_vfs_getname=$?
 
 cleanup_probe_vfs_getname() {
index c8380137beef16abee15c15340e39eea3d207ca2..9b7635184dc20e6018027045996e53648c97c61a 100755 (executable)
@@ -2,6 +2,10 @@
 #
 # Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
 
+. $(dirname $0)/lib/probe.sh
+
+skip_if_no_perf_probe || exit 2
+
 . $(dirname $0)/lib/probe_vfs_getname.sh
 
 add_probe_vfs_getname || skip_if_no_debuginfo
index 2725c5db699af6788a76cf683930eba9be8e915f..ba29535b8580a6caebfb339d4d81789b41e407ec 100755 (executable)
@@ -7,6 +7,10 @@
 
 # Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
 
+. $(dirname $0)/lib/probe.sh
+
+skip_if_no_perf_probe || exit 2
+
 . $(dirname $0)/lib/probe_vfs_getname.sh
 
 perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
index 1b9a276e2ace178d03d59f7406c6b229506b1a49..99dafad6195498d7a3ab33b6c14b4b90f94dfb61 100755 (executable)
@@ -8,6 +8,8 @@
 
 # Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
 
+. $(dirname $0)/lib/probe.sh
+
 trace_libc_inet_pton_backtrace() {
        idx=0
        expected[0]="PING.*bytes"
@@ -32,6 +34,7 @@ trace_libc_inet_pton_backtrace() {
        done
 }
 
+skip_if_no_perf_probe && \
 perf probe -q /lib64/libc-*.so inet_pton && \
 trace_libc_inet_pton_backtrace
 err=$?
index d0fba0c5e3545b4495824ff316ea318adb5972c1..2e68c5f120da87250a87b5067793e2ca75ced60c 100755 (executable)
@@ -8,6 +8,10 @@
 
 # Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
 
+. $(dirname $0)/lib/probe.sh
+
+skip_if_no_perf_probe || exit 2
+
 . $(dirname $0)/lib/probe_vfs_getname.sh
 
 file=$(mktemp /tmp/temporary_file.XXXXX)