1 # SPDX-License-Identifier: GPL-2.0
8 # This file should be used for initialization of basic functions
9 # for checking, reporting results etc.
14 . ../common/settings.sh
15 . ../common/patterns.sh
17 THIS_TEST_NAME=`basename $0 .sh`
21 test "$TESTLOG_VERBOSITY" -ne 0 && echo -e "$@"
26 PERF_RETVAL="$1"; shift
27 CHECK_RETVAL="$1"; shift
30 if [ $PERF_RETVAL -eq 0 ] && [ $CHECK_RETVAL -eq 0 ]; then
31 _echo "$MPASS-- [ PASS ] --$MEND $TEST_NAME :: $THIS_TEST_NAME :: $TASK_COMMENT"
34 if [ $PERF_RETVAL -ne 0 ]; then
35 FAILURE_REASON="command exitcode"
37 if [ $CHECK_RETVAL -ne 0 ]; then
38 test -n "$FAILURE_REASON" && FAILURE_REASON="$FAILURE_REASON + "
39 FAILURE_REASON="$FAILURE_REASON""output regexp parsing"
41 _echo "$MFAIL-- [ FAIL ] --$MEND $TEST_NAME :: $THIS_TEST_NAME :: $TASK_COMMENT ($FAILURE_REASON)"
46 print_overall_results()
50 test -n "$TASK_COMMENT" && TASK_COMMENT=":: $TASK_COMMENT"
52 if [ $RETVAL -eq 0 ]; then
53 _echo "$MALLPASS## [ PASS ] ##$MEND $TEST_NAME :: $THIS_TEST_NAME SUMMARY"
55 _echo "$MALLFAIL## [ FAIL ] ##$MEND $TEST_NAME :: $THIS_TEST_NAME SUMMARY :: $RETVAL failures found $TASK_COMMENT"
60 print_testcase_skipped()
63 _echo "$MSKIP-- [ SKIP ] --$MEND $TEST_NAME :: $THIS_TEST_NAME :: $TASK_COMMENT :: testcase skipped"
67 print_overall_skipped()
69 _echo "$MSKIP## [ SKIP ] ##$MEND $TEST_NAME :: $THIS_TEST_NAME :: testcase skipped"
76 _echo "$MWARN-- [ WARN ] --$MEND $TEST_NAME :: $THIS_TEST_NAME :: $WARN_COMMENT"
80 # this function should skip a testcase if the testsuite is not run in
81 # a runmode that fits the testcase --> if the suite runs in BASIC mode
82 # all STANDARD and EXPERIMENTAL testcases will be skipped; if the suite
83 # runs in STANDARD mode, all EXPERIMENTAL testcases will be skipped and
84 # if the suite runs in EXPERIMENTAL mode, nothing is skipped
88 # the runmode of a testcase needs to be at least the current suite's runmode
89 if [ $PERFTOOL_TESTSUITE_RUNMODE -lt $TESTCASE_RUNMODE ]; then
99 # 1 = virtualization detected
101 VIRT=`systemd-detect-virt 2>/dev/null`
102 test $? -eq 127 && return 2
103 test "$VIRT" = "none"
110 # 1 = is not Intel or unknown
111 grep "vendor_id" < /proc/cpuinfo | grep -q "GenuineIntel"
118 # 1 = is not AMD or unknown
119 grep "vendor_id" < /proc/cpuinfo | grep -q "AMD"
123 check_kprobes_available()
125 test -e /sys/kernel/debug/tracing/kprobe_events
128 check_uprobes_available()
130 test -e /sys/kernel/debug/tracing/uprobe_events
135 echo 0 > /sys/kernel/debug/tracing/events/enable
136 check_kprobes_available && echo > /sys/kernel/debug/tracing/kprobe_events
137 check_uprobes_available && echo > /sys/kernel/debug/tracing/uprobe_events
142 $CMD_PERF list sdt | grep sdt > /dev/null 2> /dev/null