From: Michael Petlan <mpetlan@redhat.com>
To: linux-perf-users@vger.kernel.org, vmolnaro@redhat.com,
acme@redhat.com, namhyung@kernel.org
Cc: acme@kernel.org, irogers@google.com, atrajeev@linux.vnet.ibm.com,
masami.hiramatsu.pt@hitachi.com
Subject: [PATCH 06/11] perf testsuite probe: Add test for invalid options
Date: Mon, 24 Jun 2024 15:08:04 +0200 [thread overview]
Message-ID: <20240624130809.1612-7-mpetlan@redhat.com> (raw)
In-Reply-To: <20240624130809.1612-1-mpetlan@redhat.com>
From: Veronika Molnarova <vmolnaro@redhat.com>
Test if various incompatible options are correctly handled-rejected.
It is run as a part of perftool-testsuite_probe test case.
Signed-off-by: Veronika Molnarova <vmolnaro@redhat.com>
Signed-off-by: Michael Petlan <mpetlan@redhat.com>
---
.../shell/base_probe/test_invalid_options.sh | 79 +++++++++++++++++++
1 file changed, 79 insertions(+)
create mode 100755 tools/perf/tests/shell/base_probe/test_invalid_options.sh
diff --git a/tools/perf/tests/shell/base_probe/test_invalid_options.sh b/tools/perf/tests/shell/base_probe/test_invalid_options.sh
new file mode 100755
index 000000000000..1fedfd8b0d0d
--- /dev/null
+++ b/tools/perf/tests/shell/base_probe/test_invalid_options.sh
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+# SPDX-License-Identifier: GPL-2.0
+
+#
+# test_invalid_options of perf_probe test
+# Author: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
+# Author: Michael Petlan <mpetlan@redhat.com>
+#
+# Description:
+#
+# This test checks whether the invalid and incompatible options are reported
+#
+
+# include working environment
+. ../common/init.sh
+
+TEST_RESULT=0
+
+if ! check_kprobes_available; then
+ print_overall_skipped
+ exit 0
+fi
+
+
+### missing argument
+
+# some options require an argument
+for opt in '-a' '-d' '-L' '-V'; do
+ ! $CMD_PERF probe $opt 2> $LOGS_DIR/invalid_options_missing_argument$opt.err
+ PERF_EXIT_CODE=$?
+
+ ../common/check_all_patterns_found.pl "Error: switch .* requires a value" < $LOGS_DIR/invalid_options_missing_argument$opt.err
+ CHECK_EXIT_CODE=$?
+
+ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "missing argument for $opt"
+ (( TEST_RESULT += $? ))
+done
+
+
+### unnecessary argument
+
+# some options may omit the argument
+for opt in '-F' '-l'; do
+ $CMD_PERF probe -F > /dev/null 2> $LOGS_DIR/invalid_options_unnecessary_argument$opt.err
+ PERF_EXIT_CODE=$?
+
+ test ! -s $LOGS_DIR/invalid_options_unnecessary_argument$opt.err
+ CHECK_EXIT_CODE=$?
+
+ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "unnecessary argument for $opt"
+ (( TEST_RESULT += $? ))
+done
+
+
+### mutually exclusive options
+
+# some options are mutually exclusive
+test -e $LOGS_DIR/invalid_options_mutually_exclusive.log && rm -f $LOGS_DIR/invalid_options_mutually_exclusive.log
+for opt in '-a xxx -d xxx' '-a xxx -L foo' '-a xxx -V foo' '-a xxx -l' '-a xxx -F' \
+ '-d xxx -L foo' '-d xxx -V foo' '-d xxx -l' '-d xxx -F' \
+ '-L foo -V bar' '-L foo -l' '-L foo -F' '-V foo -l' '-V foo -F' '-l -F'; do
+ ! $CMD_PERF probe $opt > /dev/null 2> $LOGS_DIR/aux.log
+ PERF_EXIT_CODE=$?
+
+ ../common/check_all_patterns_found.pl "Error: switch .+ cannot be used with switch .+" < $LOGS_DIR/aux.log
+ CHECK_EXIT_CODE=$?
+
+ print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "mutually exclusive options :: $opt"
+ (( TEST_RESULT += $? ))
+
+ # gather the logs
+ cat $LOGS_DIR/aux.log | grep "Error" >> $LOGS_DIR/invalid_options_mutually_exclusive.log
+done
+
+
+# print overall results
+print_overall_results "$TEST_RESULT"
+exit $?
--
2.43.0
next prev parent reply other threads:[~2024-06-24 13:08 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-24 13:07 [PATCH 00/11] perftool-testsuite 2nd batch Michael Petlan
2024-06-24 13:07 ` [PATCH 01/11] perf tests shell: Skip base_* dirs in test script search Michael Petlan
2024-06-24 13:08 ` [PATCH 02/11] perf testsuite: Merge settings files for shell tests Michael Petlan
2024-06-24 13:08 ` [PATCH 03/11] perf testsuite: Fix shellcheck warnings Michael Petlan
2024-06-24 13:08 ` [PATCH 04/11] perf testsuite probe: Add test for blacklisted kprobes handling Michael Petlan
2024-06-24 13:08 ` [PATCH 05/11] perf testsuite probe: Add test for basic perf-probe options Michael Petlan
2024-06-24 13:08 ` Michael Petlan [this message]
2024-06-24 13:08 ` [PATCH 07/11] perf testsuite probe: Add test for line semantics Michael Petlan
2024-06-24 13:08 ` [PATCH 08/11] perf testsuite: Add common output checking helper Michael Petlan
2024-06-24 13:08 ` [PATCH 09/11] perf testsuite report: Add test for perf-report basic functionality Michael Petlan
2024-06-24 13:08 ` [PATCH 10/11] perf testsuite report: Add test case for perf report Michael Petlan
2024-06-24 13:08 ` [PATCH 11/11] perf testsuite: Install perf-report tests Michael Petlan
2024-06-27 22:29 ` [PATCH 00/11] perftool-testsuite 2nd batch Namhyung Kim
2024-07-02 11:08 ` [PATCH v2 " vmolnaro
2024-07-02 11:08 ` [PATCH v2 01/11] perf tests shell: Skip base_* dirs in test script search vmolnaro
2024-07-02 11:08 ` [PATCH v2 02/11] perf testsuite: Merge settings files for shell tests vmolnaro
2024-07-02 11:08 ` [PATCH v2 03/11] perf testsuite: Fix shellcheck warnings vmolnaro
2024-07-02 11:08 ` [PATCH v2 04/11] perf testsuite probe: Add test for blacklisted kprobes handling vmolnaro
2024-07-02 11:08 ` [PATCH v2 05/11] perf testsuite probe: Add test for basic perf-probe options vmolnaro
2024-07-02 11:08 ` [PATCH v2 06/11] perf testsuite probe: Add test for invalid options vmolnaro
2024-07-02 11:08 ` [PATCH v2 07/11] perf testsuite probe: Add test for line semantics vmolnaro
2024-07-02 11:08 ` [PATCH v2 08/11] perf testsuite: Add common output checking helper vmolnaro
2024-07-02 11:08 ` [PATCH v2 09/11] perf testsuite report: Add test for perf-report basic functionality vmolnaro
2024-07-02 11:08 ` [PATCH v2 10/11] perf testsuite report: Add test case for perf report vmolnaro
2024-07-02 11:08 ` [PATCH v2 11/11] perf testsuite: Install perf-report tests vmolnaro
2024-08-28 14:10 ` [PATCH v2 00/11] perftool-testsuite 2nd batch Veronika Molnarova
2024-08-28 20:39 ` Arnaldo Carvalho de Melo
2024-08-29 11:29 ` [PATCH v2 01/11] perf tests shell: Skip base_* dirs in test script search vmolnaro
2024-08-29 11:29 ` [PATCH v2 11/11] perf testsuite: Install perf-report tests vmolnaro
2024-08-30 15:27 ` [PATCH v2 00/11] perftool-testsuite 2nd batch Arnaldo Carvalho de Melo
2024-09-02 14:05 ` Veronika Molnarova
2024-09-02 14:31 ` Arnaldo Carvalho de Melo
2024-09-02 14:41 ` Arnaldo Carvalho de Melo
2024-09-02 14:42 ` Arnaldo Carvalho de Melo
2024-09-02 15:10 ` Veronika Molnarova
2024-09-02 18:46 ` Arnaldo Carvalho de Melo
2024-09-02 21:00 ` Arnaldo Carvalho de Melo
2024-09-05 15:11 ` Masami Hiramatsu
2024-09-05 19:04 ` Arnaldo Carvalho de Melo
2024-09-05 19:15 ` Arnaldo Carvalho de Melo
2024-09-12 13:07 ` Arnaldo Carvalho de Melo
2024-09-19 13:14 ` Veronika Molnarova
2024-09-26 22:33 ` 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=20240624130809.1612-7-mpetlan@redhat.com \
--to=mpetlan@redhat.com \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=atrajeev@linux.vnet.ibm.com \
--cc=irogers@google.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=namhyung@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).