brintos

brintos / linux-shallow public Read only

0
0
Text · 1.2 KiB · 5a3b8a5 Raw
63 lines · bash
1#!/bin/sh2# perf trace enum augmentation tests3# SPDX-License-Identifier: GPL-2.04 5err=06set -e7 8syscall="landlock_add_rule"9non_syscall="timer:hrtimer_init,timer:hrtimer_start"10 11TESTPROG="perf test -w landlock"12 13# shellcheck source=lib/probe.sh14. "$(dirname $0)"/lib/probe.sh15skip_if_no_perf_trace || exit 216 17check_vmlinux() {18  echo "Checking if vmlinux exists"19  if ! ls /sys/kernel/btf/vmlinux 1>/dev/null 2>&120  then21    echo "trace+enum test [Skipped missing vmlinux BTF support]"22    err=223  fi24}25 26trace_landlock() {27  echo "Tracing syscall ${syscall}"28 29  # test flight just to see if landlock_add_rule and libbpf are available30  $TESTPROG31 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  then35    err=036  else37    err=138  fi39}40 41trace_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  then46    err=047  else48    err=149  fi50}51 52check_vmlinux53 54if [ $err = 0 ]; then55  trace_landlock56fi57 58if [ $err = 0 ]; then59  trace_non_syscall60fi61 62exit $err63