From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Tianyi Chen <hi@tychen.cc>, Andrew Morton <akpm@linux-foundation.org>
Cc: shuah@kernel.org, linux-mm@kvack.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
jsavitz@redhat.com
Subject: Re: [PATCH v2 1/2] selftests/mm: Reject invalid test selections before running tests
Date: Tue, 8 Sep 2026 12:13:32 +0200 [thread overview]
Message-ID: <d6ca7f47-39bb-43b4-92d6-63ccc148ebdd@kernel.org> (raw)
In-Reply-To: <178886112560.138404.14562368683011041790.mm-cli-v2-1@tychen.cc>
On 9/8/26 11:55, Tianyi Chen wrote:
> getopts reports unknown options and missing arguments, but run_vmtests.sh
> ignores its error result and continues with test setup. An empty -t
> argument also falls back to the default selection, while unknown category
> names can silently select no tests and still reach setup code.
>
> Exit on getopts errors and validate category names against the existing
> list in usage() before any test setup. Reject empty and whitespace-only
> selections, and normalize category separators so validation and execution
> agree. Keep the default selection for an unset or empty VM_SELFTEST_ITEMS
> environment variable, and preserve the existing standalone default value.
>
> Fixes: 85463321e726 ("selftests/vm: enable running select groups of tests")
> Assisted-by: Codex:GPT-6
> Signed-off-by: Tianyi Chen <hi@tychen.cc>
> ---
> tools/testing/selftests/mm/run_vmtests.sh | 27 +++++++++++++++++++----
> 1 file changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh
> index d09f9f6a384..836c7454cba 100755
> --- a/tools/testing/selftests/mm/run_vmtests.sh
> +++ b/tools/testing/selftests/mm/run_vmtests.sh
> @@ -96,26 +96,45 @@ separated by spaces:
>
> example: ./run_vmtests.sh -t "hmm mmap ksm"
> EOF
> - exit 0
> }
>
> RUN_ALL=false
> RUN_DESTRUCTIVE=false
> TAP_PREFIX="# "
>
> +# An unset or empty environment selection keeps the default behavior.
> +VM_SELFTEST_ITEMS=${VM_SELFTEST_ITEMS:-default}
Who would set it at this point?
Can't this just be
VM_SELFTEST_ITEMS="default"
> +
> while getopts "aht:nd" OPT; do
> case ${OPT} in
> "a") RUN_ALL=true ;;
> - "h") usage ;;
> + "h") usage; exit 0 ;;
> "t") VM_SELFTEST_ITEMS=${OPTARG} ;;
> "n") TAP_PREFIX= ;;
> "d") RUN_DESTRUCTIVE=true ;;
> + "?") exit 1 ;;
> esac
> done
> shift $((OPTIND -1))
>
> -# default behavior: run all tests
> -VM_SELFTEST_ITEMS=${VM_SELFTEST_ITEMS:-default}
> +# Normalize whitespace so validation and test_selected() use the same names.
> +read -r -a selected_categories <<< "${VM_SELFTEST_ITEMS//$'\n'/ }"
> +VM_SELFTEST_ITEMS="${selected_categories[*]}"
> +if [ -z "$VM_SELFTEST_ITEMS" ]; then
> + echo "No test categories specified" >&2
> + exit 1
> +fi
> +
> +if [ "$VM_SELFTEST_ITEMS" != "default" ]; then
> + # Keep the documented category list as the source of valid names.
That makes sense to me.
It's interesting what would happen when trying to run a test that does not even
exist for the architecture. Getting some feedback that the test was skipped
would be nice. But that's something for another day :)
--
Cheers,
David
next prev parent reply other threads:[~2026-09-08 10:13 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 ` [PATCH RESEND] selftests/mm: Exit on invalid command-line options Tianyi Chen
2026-09-07 11:47 ` 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) [this message]
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=d6ca7f47-39bb-43b4-92d6-63ccc148ebdd@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=hi@tychen.cc \
--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
all inboxes | Powered by JetHome®