OSDN Git Service

perf test shell: Use a fallback to get the pathname in vfs_getname
[uclinux-h8/linux.git] / tools / perf / tests / shell / record+script_probe_vfs_getname.sh
1 #!/bin/sh
2 # Use vfs_getname probe to get syscall args filenames
3
4 # Uses the 'perf test shell' library to add probe:vfs_getname to the system
5 # then use it with 'perf record' using 'touch' to write to a temp file, then
6 # checks that that was captured by the vfs_getname probe in the generated
7 # perf.data file, with the temp file name as the pathname argument.
8
9 # Arnaldo Carvalho de Melo <acme@kernel.org>, 2017
10
11 . $(dirname $0)/lib/probe.sh
12
13 skip_if_no_perf_probe || exit 2
14
15 . $(dirname $0)/lib/probe_vfs_getname.sh
16
17 perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
18 file=$(mktemp /tmp/temporary_file.XXXXX)
19
20 record_open_file() {
21         echo "Recording open file:"
22         perf record -o ${perfdata} -e probe:vfs_getname touch $file
23 }
24
25 perf_script_filenames() {
26         echo "Looking at perf.data file for vfs_getname records for the file we touched:"
27         perf script -i ${perfdata} | \
28         egrep " +touch +[0-9]+ +\[[0-9]+\] +[0-9]+\.[0-9]+: +probe:vfs_getname: +\([[:xdigit:]]+\) +pathname=\"${file}\""
29 }
30
31 add_probe_vfs_getname || skip_if_no_debuginfo
32 err=$?
33 if [ $err -ne 0 ] ; then
34         exit $err
35 fi
36
37 record_open_file && perf_script_filenames
38 err=$?
39 rm -f ${perfdata}
40 rm -f ${file}
41 cleanup_probe_vfs_getname
42 exit $err