From: Tianyi Chen <hi@tychen.cc>
To: Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>
Cc: Tianyi Chen <hi@tychen.cc>, Shuah Khan <shuah@kernel.org>,
linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, Joel Savitz <jsavitz@redhat.com>
Subject: [PATCH RESEND] selftests/mm: Exit on invalid command-line options
Date: Sun, 6 Sep 2026 21:54:39 +0800 [thread overview]
Message-ID: <20260906135444.749144-1-hi@tychen.cc> (raw)
In-Reply-To: <ZTYJZT7Q8UU4.KPP9BUAAJVQO1@mailcore-89d674988-v7w7p>
getopts reports unknown options and missing option arguments, but
run_vmtests.sh ignores its error result and continues running tests.
For example, passing -z or omitting the argument to -t can run the
default test selection instead of rejecting the command.
Exit with failure when getopts reports an error, before any tests or
their setup run. Keep the diagnostic provided by getopts.
Verified that -z, -t and -t mmap -z exit with status 1, while -h still
exits with status 0. The mmap category's three test programs pass in
a VM running the kernel built from the same source tree.
Fixes: 85463321e726 ("selftests/vm: enable running select groups of tests")
Assisted-by: LLM
Signed-off-by: Tianyi Chen <hi@tychen.cc>
---
Resending because the webmail editor damaged the whitespace in the
previous submission. The code change is unchanged.
tools/testing/selftests/mm/run_vmtests.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
index d09f9f6a384..189927f87e6 100755
--- a/tools/testing/selftests/mm/run_vmtests.sh
+++ b/tools/testing/selftests/mm/run_vmtests.sh
@@ -110,6 +110,7 @@ while getopts "aht:nd" OPT; do
"t") VM_SELFTEST_ITEMS=${OPTARG} ;;
"n") TAP_PREFIX= ;;
"d") RUN_DESTRUCTIVE=true ;;
+ "?") exit 1 ;;
esac
done
shift $((OPTIND -1))
--
2.55.0
next parent reply other threads:[~2026-09-06 13:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <ZTYJZT7Q8UU4.KPP9BUAAJVQO1@mailcore-89d674988-v7w7p>
2026-09-06 13:54 ` Tianyi Chen [this message]
2026-09-07 11:47 ` [PATCH RESEND] selftests/mm: Exit on invalid command-line options David Hildenbrand (Arm)
2026-09-08 9:55 ` Tianyi Chen
2026-09-08 9:55 ` [PATCH v2 0/2] selftests/mm: Validate selections and scope memfd_secret setup Tianyi Chen
2026-09-08 9:55 ` [PATCH v2 1/2] selftests/mm: Reject invalid test selections before running tests Tianyi Chen
2026-09-08 10:13 ` David Hildenbrand (Arm)
2026-09-08 9:55 ` [PATCH v2 2/2] selftests/mm: Only prepare ptrace_scope when memfd_secret is selected Tianyi Chen
2026-09-08 10:14 ` David Hildenbrand (Arm)
2026-09-08 10:15 ` [PATCH v2 0/2] selftests/mm: Validate selections and scope memfd_secret setup David Hildenbrand (Arm)
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=20260906135444.749144-1-hi@tychen.cc \
--to=hi@tychen.cc \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=jsavitz@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shuah@kernel.org \
/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).