Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/ftrace: Move kprobe/uprobe check_error() to test.d/functions

The k/uprobe_sytax_errors test case defines a check_error() function
used to run a command and check the position of the caret in the
output.

This would be useful for other ftrace facilities too, so move it to
test.d/functions for use by anyone. In the process, rename it to
ftrace_errlog_check() and parametrize it for general use.

Link: http://lkml.kernel.org/r/9f88080a06f1755811f69081926afe7e5cb53178.1554072478.git.tom.zanussi@linux.intel.com

Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

authored by

Tom Zanussi and committed by
Steven Rostedt (VMware)
c5e4114f 8ab4483e

+14 -18
+12
tools/testing/selftests/ftrace/test.d/functions
··· 109 109 yield() { 110 110 ping $LOCALHOST -c 1 || sleep .001 || usleep 1 || sleep 1 111 111 } 112 + 113 + ftrace_errlog_check() { # err-prefix command-with-error-pos-by-^ command-file 114 + pos=$(echo -n "${2%^*}" | wc -c) # error position 115 + command=$(echo "$2" | tr -d ^) 116 + echo "Test command: $command" 117 + echo > error_log 118 + (! echo "$command" > "$3" ) 2> /dev/null 119 + grep "$1: error:" -A 3 error_log 120 + N=$(tail -n 1 error_log | wc -c) 121 + # " Command: " and "^\n" => 13 122 + test $(expr 13 + $pos) -eq $N 123 + }
+1 -9
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc
··· 7 7 [ -f error_log ] || exit_unsupported 8 8 9 9 check_error() { # command-with-error-pos-by-^ 10 - pos=$(echo -n "${1%^*}" | wc -c) # error position 11 - command=$(echo "$1" | tr -d ^) 12 - echo "Test command: $command" 13 - echo > error_log 14 - (! echo "$command" > kprobe_events ) 2> /dev/null 15 - grep "trace_kprobe: error:" -A 3 error_log 16 - N=$(tail -n 1 error_log | wc -c) 17 - # " Command: " and "^\n" => 13 18 - test $(expr 13 + $pos) -eq $N 10 + ftrace_errlog_check 'trace_kprobe' "$1" 'kprobe_events' 19 11 } 20 12 21 13 if grep -q 'r\[maxactive\]' README; then
+1 -9
tools/testing/selftests/ftrace/test.d/kprobe/uprobe_syntax_errors.tc
··· 7 7 [ -f error_log ] || exit_unsupported 8 8 9 9 check_error() { # command-with-error-pos-by-^ 10 - pos=$(echo -n "${1%^*}" | wc -c) # error position 11 - command=$(echo "$1" | tr -d ^) 12 - echo "Test command: $command" 13 - echo > error_log 14 - (! echo "$command" > uprobe_events ) 2> /dev/null 15 - grep "trace_uprobe: error:" -A 3 error_log 16 - N=$(tail -n 1 error_log | wc -c) 17 - # " Command: " and "^\n" => 13 18 - test $(expr 13 + $pos) -eq $N 10 + ftrace_errlog_check 'trace_uprobe' "$1" 'uprobe_events' 19 11 } 20 12 21 13 check_error 'p ^/non_exist_file:100' # FILE_NOT_FOUND