Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1#!/bin/bash
2# perf_probe :: Basic perf probe functionality (exclusive)
3# SPDX-License-Identifier: GPL-2.0
4
5#
6# test_basic of perf_probe test
7# Author: Michael Petlan <mpetlan@redhat.com>
8# Author: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
9#
10# Description:
11#
12# This test tests basic functionality of perf probe command.
13#
14
15DIR_PATH="$(dirname $0)"
16TEST_RESULT=0
17
18# include working environment
19. "$DIR_PATH/../common/init.sh"
20
21if ! check_kprobes_available; then
22 print_overall_skipped
23 exit 2
24fi
25
26
27### help message
28
29if [ "$PARAM_GENERAL_HELP_TEXT_CHECK" = "y" ]; then
30 # test that a help message is shown and looks reasonable
31 $CMD_PERF probe --help > $LOGS_DIR/basic_helpmsg.log 2> $LOGS_DIR/basic_helpmsg.err
32 PERF_EXIT_CODE=$?
33
34 "$DIR_PATH/../common/check_all_patterns_found.pl" \
35 "PERF-PROBE" "NAME" "SYNOPSIS" "DESCRIPTION" "OPTIONS" \
36 "PROBE\s+SYNTAX" "PROBE\s+ARGUMENT" "LINE\s+SYNTAX" \
37 < $LOGS_DIR/basic_helpmsg.log
38 CHECK_EXIT_CODE=$?
39 "$DIR_PATH/../common/check_all_patterns_found.pl" \
40 "LAZY\s+MATCHING" "FILTER\s+PATTERN" "EXAMPLES" "SEE\s+ALSO" \
41 < $LOGS_DIR/basic_helpmsg.log
42 (( CHECK_EXIT_CODE += $? ))
43 "$DIR_PATH/../common/check_all_patterns_found.pl" \
44 "vmlinux" "module=" "source=" "verbose" "quiet" "add=" "del=" \
45 "list.*EVENT" "line=" "vars=" "externs" < $LOGS_DIR/basic_helpmsg.log
46 (( CHECK_EXIT_CODE += $? ))
47 "$DIR_PATH/../common/check_all_patterns_found.pl" \
48 "no-inlines" "funcs.*FILTER" "filter=FILTER" "force" "dry-run" \
49 "max-probes" "exec=" "demangle-kernel" < $LOGS_DIR/basic_helpmsg.log
50 (( CHECK_EXIT_CODE += $? ))
51 "$DIR_PATH/../common/check_no_patterns_found.pl" \
52 "No manual entry for" < $LOGS_DIR/basic_helpmsg.err
53 (( CHECK_EXIT_CODE += $? ))
54
55 print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "help message"
56 (( TEST_RESULT += $? ))
57else
58 print_testcase_skipped "help message"
59fi
60
61
62### usage message
63
64# without any args perf-probe should print usage
65$CMD_PERF probe 2> $LOGS_DIR/basic_usage.log > /dev/null
66
67"$DIR_PATH/../common/check_all_patterns_found.pl" \
68 "[Uu]sage" "perf probe" "verbose" "quiet" "add" "del" "force" \
69 "line" "vars" "externs" "range" < $LOGS_DIR/basic_usage.log
70CHECK_EXIT_CODE=$?
71
72print_results 0 $CHECK_EXIT_CODE "usage message"
73(( TEST_RESULT += $? ))
74
75
76### quiet switch
77
78# '--quiet' should mute all output
79$CMD_PERF probe --quiet --add vfs_read > $LOGS_DIR/basic_quiet01.log 2> $LOGS_DIR/basic_quiet01.err
80PERF_EXIT_CODE=$?
81$CMD_PERF probe --quiet --del vfs_read > $LOGS_DIR/basic_quiet03.log 2> $LOGS_DIR/basic_quiet02.err
82(( PERF_EXIT_CODE += $? ))
83
84test "`cat $LOGS_DIR/basic_quiet*log $LOGS_DIR/basic_quiet*err | wc -l`" -eq 0
85CHECK_EXIT_CODE=$?
86
87print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "quiet switch"
88(( TEST_RESULT += $? ))
89
90
91# print overall results
92print_overall_results "$TEST_RESULT"
93exit $?