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