Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / perf / tests / shell / trace_btf_enum.sh
blob5a3b8a5a9b5cf2961891241fea7c8d09f95fd1df
1 #!/bin/sh
2 # perf trace enum augmentation tests
3 # SPDX-License-Identifier: GPL-2.0
5 err=0
6 set -e
8 syscall="landlock_add_rule"
9 non_syscall="timer:hrtimer_init,timer:hrtimer_start"
11 TESTPROG="perf test -w landlock"
13 # shellcheck source=lib/probe.sh
14 . "$(dirname $0)"/lib/probe.sh
15 skip_if_no_perf_trace || exit 2
17 check_vmlinux() {
18 echo "Checking if vmlinux exists"
19 if ! ls /sys/kernel/btf/vmlinux 1>/dev/null 2>&1
20 then
21 echo "trace+enum test [Skipped missing vmlinux BTF support]"
22 err=2
26 trace_landlock() {
27 echo "Tracing syscall ${syscall}"
29 # test flight just to see if landlock_add_rule and libbpf are available
30 $TESTPROG
32 if perf trace -e $syscall $TESTPROG 2>&1 | \
33 grep -q -E ".*landlock_add_rule\(ruleset_fd: 11, rule_type: (LANDLOCK_RULE_PATH_BENEATH|LANDLOCK_RULE_NET_PORT), rule_attr: 0x[a-f0-9]+, flags: 45\) = -1.*"
34 then
35 err=0
36 else
37 err=1
41 trace_non_syscall() {
42 echo "Tracing non-syscall tracepoint ${non-syscall}"
43 if perf trace -e $non_syscall --max-events=1 2>&1 | \
44 grep -q -E '.*timer:hrtimer_.*\(.*mode: HRTIMER_MODE_.*\)$'
45 then
46 err=0
47 else
48 err=1
52 check_vmlinux
54 if [ $err = 0 ]; then
55 trace_landlock
58 if [ $err = 0 ]; then
59 trace_non_syscall
62 exit $err