~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/tests/shell/ftrace.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/sh
  2 # perf ftrace tests
  3 # SPDX-License-Identifier: GPL-2.0
  4 
  5 set -e
  6 
  7 # perf ftrace commands only works for root
  8 if [ "$(id -u)" != 0 ]; then
  9     echo "perf ftrace test  [Skipped: no permission]"
 10     exit 2
 11 fi
 12 
 13 output=$(mktemp /tmp/__perf_test.ftrace.XXXXXX)
 14 
 15 cleanup() {
 16   rm -f "${output}"
 17 
 18   trap - EXIT TERM INT
 19 }
 20 
 21 trap_cleanup() {
 22   cleanup
 23   exit 1
 24 }
 25 trap trap_cleanup EXIT TERM INT
 26 
 27 # this will be set in test_ftrace_trace()
 28 target_function=
 29 
 30 test_ftrace_list() {
 31     echo "perf ftrace list test"
 32     perf ftrace -F > "${output}"
 33     # this will be used in test_ftrace_trace()
 34     sleep_functions=$(grep 'sys_.*sleep$' "${output}")
 35     echo "syscalls for sleep:"
 36     echo "${sleep_functions}"
 37     echo "perf ftrace list test  [Success]"
 38 }
 39 
 40 test_ftrace_trace() {
 41     echo "perf ftrace trace test"
 42     perf ftrace trace --graph-opts depth=5 sleep 0.1 > "${output}"
 43     # it should have some function name contains 'sleep'
 44     grep "^#" "${output}"
 45     grep -F 'sleep()' "${output}"
 46     # find actual syscall function name
 47     for FN in ${sleep_functions}; do
 48         if grep -q "${FN}" "${output}"; then
 49             target_function="${FN}"
 50             echo "perf ftrace trace test  [Success]"
 51             return
 52         fi
 53     done
 54 
 55     echo "perf ftrace trace test  [Failure: sleep syscall not found]"
 56     exit 1
 57 }
 58 
 59 test_ftrace_latency() {
 60     echo "perf ftrace latency test"
 61     echo "target function: ${target_function}"
 62     perf ftrace latency -T "${target_function}" sleep 0.1 > "${output}"
 63     grep "^#" "${output}"
 64     grep "###" "${output}"
 65     echo "perf ftrace latency test  [Success]"
 66 }
 67 
 68 test_ftrace_profile() {
 69     echo "perf ftrace profile test"
 70     perf ftrace profile sleep 0.1 > "${output}"
 71     grep ^# "${output}"
 72     grep sleep "${output}"
 73     grep schedule "${output}"
 74     grep execve "${output}"
 75     time_re="[[:space:]]+10[[:digit:]]{4}\.[[:digit:]]{3}"
 76     # 100283.000 100283.000 100283.000          1   __x64_sys_clock_nanosleep
 77     # Check for one *clock_nanosleep line with a Count of just 1 that takes a bit more than 0.1 seconds
 78     # Strip the _x64_sys part to work with other architectures
 79     grep -E "^${time_re}${time_re}${time_re}[[:space:]]+1[[:space:]]+.*clock_nanosleep" "${output}"
 80     echo "perf ftrace profile test  [Success]"
 81 }
 82 
 83 test_ftrace_list
 84 test_ftrace_trace
 85 test_ftrace_latency
 86 test_ftrace_profile
 87 
 88 cleanup
 89 exit 0

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php