From: Michael Petlan <mpetlan@redhat.com>
To: linux-perf-users@vger.kernel.org, vmolnaro@redhat.com,
acme@redhat.com, acme@kernel.org
Cc: mhiramat@kernel.org
Subject: [PATCH 3/7] perf testsuite: Add initialization script for shell tests
Date: Wed, 31 Jan 2024 12:39:47 +0100 [thread overview]
Message-ID: <20240131113951.17077-3-mpetlan@redhat.com> (raw)
In-Reply-To: <20240131113951.17077-1-mpetlan@redhat.com>
From: Veronika Molnarova <vmolnaro@redhat.com>
Initialize reporting and logging functions that unifies formatting
of the test output used for shell tests.
Signed-off-by: Veronika Molnarova <vmolnaro@redhat.com>
Signed-off-by: Michael Petlan <mpetlan@redhat.com>
---
tools/perf/tests/shell/common/init.sh | 117 ++++++++++++++++++++++++++
1 file changed, 117 insertions(+)
create mode 100644 tools/perf/tests/shell/common/init.sh
diff --git a/tools/perf/tests/shell/common/init.sh b/tools/perf/tests/shell/common/init.sh
new file mode 100644
index 000000000000..aadeaf782e03
--- /dev/null
+++ b/tools/perf/tests/shell/common/init.sh
@@ -0,0 +1,117 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# init.sh
+# Author: Michael Petlan <mpetlan@redhat.com>
+#
+# Description:
+#
+# This file should be used for initialization of basic functions
+# for checking, reporting results etc.
+#
+#
+
+
+. ../common/settings.sh
+. ../common/patterns.sh
+
+THIS_TEST_NAME=`basename $0 .sh`
+
+_echo()
+{
+ test "$TESTLOG_VERBOSITY" -ne 0 && echo -e "$@"
+}
+
+print_results()
+{
+ PERF_RETVAL="$1"; shift
+ CHECK_RETVAL="$1"; shift
+ FAILURE_REASON=""
+ TASK_COMMENT="$@"
+ if [ $PERF_RETVAL -eq 0 -a $CHECK_RETVAL -eq 0 ]; then
+ _echo "$MPASS-- [ PASS ] --$MEND $TEST_NAME :: $THIS_TEST_NAME :: $TASK_COMMENT"
+ return 0
+ else
+ if [ $PERF_RETVAL -ne 0 ]; then
+ FAILURE_REASON="command exitcode"
+ fi
+ if [ $CHECK_RETVAL -ne 0 ]; then
+ test -n "$FAILURE_REASON" && FAILURE_REASON="$FAILURE_REASON + "
+ FAILURE_REASON="$FAILURE_REASON""output regexp parsing"
+ fi
+ _echo "$MFAIL-- [ FAIL ] --$MEND $TEST_NAME :: $THIS_TEST_NAME :: $TASK_COMMENT ($FAILURE_REASON)"
+ return 1
+ fi
+}
+
+print_overall_results()
+{
+ RETVAL="$1"; shift
+ if [ $RETVAL -eq 0 ]; then
+ _echo "$MALLPASS## [ PASS ] ##$MEND $TEST_NAME :: $THIS_TEST_NAME SUMMARY"
+ else
+ _echo "$MALLFAIL## [ FAIL ] ##$MEND $TEST_NAME :: $THIS_TEST_NAME SUMMARY :: $RETVAL failures found"
+ fi
+ return $RETVAL
+}
+
+print_testcase_skipped()
+{
+ TASK_COMMENT="$@"
+ _echo "$MSKIP-- [ SKIP ] --$MEND $TEST_NAME :: $THIS_TEST_NAME :: $TASK_COMMENT :: testcase skipped"
+ return 0
+}
+
+print_overall_skipped()
+{
+ _echo "$MSKIP## [ SKIP ] ##$MEND $TEST_NAME :: $THIS_TEST_NAME :: testcase skipped"
+ return 0
+}
+
+print_warning()
+{
+ WARN_COMMENT="$@"
+ _echo "$MWARN-- [ WARN ] --$MEND $TEST_NAME :: $THIS_TEST_NAME :: $WARN_COMMENT"
+ return 0
+}
+
+# this function should skip a testcase if the testsuite is not run in
+# a runmode that fits the testcase --> if the suite runs in BASIC mode
+# all STANDARD and EXPERIMENTAL testcases will be skipped; if the suite
+# runs in STANDARD mode, all EXPERIMENTAL testcases will be skipped and
+# if the suite runs in EXPERIMENTAL mode, nothing is skipped
+consider_skipping()
+{
+ TESTCASE_RUNMODE="$1"
+ # the runmode of a testcase needs to be at least the current suite's runmode
+ if [ $PERFTOOL_TESTSUITE_RUNMODE -lt $TESTCASE_RUNMODE ]; then
+ print_overall_skipped
+ exit 0
+ fi
+}
+
+detect_baremetal()
+{
+ # return values:
+ # 0 = bare metal
+ # 1 = virtualization detected
+ # 2 = unknown state
+ VIRT=`systemd-detect-virt 2>/dev/null`
+ test $? -eq 127 && return 2
+ test "$VIRT" = "none"
+}
+
+detect_intel()
+{
+ # return values:
+ # 0 = is Intel
+ # 1 = is not Intel or unknown
+ grep "vendor_id" < /proc/cpuinfo | grep -q "GenuineIntel"
+}
+
+detect_amd()
+{
+ # return values:
+ # 0 = is AMD
+ # 1 = is not AMD or unknown
+ grep "vendor_id" < /proc/cpuinfo | grep -q "AMD"
+}
--
2.43.0
next prev parent reply other threads:[~2024-01-31 11:40 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-31 11:39 [PATCH 1/7] perf testsuite: Add common regex patters Michael Petlan
2024-01-31 11:39 ` [PATCH 2/7] perf testsuite: Add common setting for shell tests Michael Petlan
2024-01-31 11:39 ` Michael Petlan [this message]
2024-01-31 11:39 ` [PATCH 4/7] perf testsuite: Add test case for perf probe Michael Petlan
2024-01-31 11:39 ` [PATCH 5/7] perf testsuite: Add common output checking helpers Michael Petlan
2024-01-31 11:39 ` [PATCH 6/7] perf testsuite: Add test for kprobe handling Michael Petlan
2024-01-31 11:39 ` [PATCH 7/7] perf testsuite: Install kprobe tests and common files Michael Petlan
2024-01-31 13:47 ` [PATCH 1/7] perf testsuite: Add common regex patters Arnaldo Carvalho de Melo
2024-01-31 13:53 ` Arnaldo Carvalho de Melo
2024-02-01 23:59 ` Namhyung Kim
2024-02-02 0:05 ` Namhyung Kim
2024-02-08 16:49 ` Michael Petlan
2024-02-09 7:13 ` Namhyung Kim
2024-02-09 22:56 ` Namhyung Kim
2024-02-15 11:02 ` [PATCH v2 0/7] Add perf testsuite into perf-test Michael Petlan
2024-02-15 11:02 ` [PATCH v2 1/7] perf testsuite: Add common regex patters Michael Petlan
2024-02-15 11:02 ` [PATCH v2 2/7] perf testsuite: Add common setting for shell tests Michael Petlan
2024-02-15 11:02 ` [PATCH v2 3/7] perf testsuite: Add initialization script " Michael Petlan
2024-02-15 11:02 ` [PATCH v2 4/7] perf testsuite: Add test case for perf probe Michael Petlan
2024-02-15 11:02 ` [PATCH v2 5/7] perf testsuite: Add common output checking helpers Michael Petlan
2024-02-15 11:02 ` [PATCH v2 6/7] perf testsuite: Add test for kprobe handling Michael Petlan
2024-02-15 11:02 ` [PATCH v2 7/7] perf testsuite: Install kprobe tests and common files Michael Petlan
2024-02-21 1:58 ` [PATCH v2 0/7] Add perf testsuite into perf-test Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240131113951.17077-3-mpetlan@redhat.com \
--to=mpetlan@redhat.com \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=vmolnaro@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).