* [PATCH] selftests/mm: Exit on invalid command-line options
@ 2026-09-06 13:44 hi
2026-09-06 13:54 ` [PATCH RESEND] " Tianyi Chen
0 siblings, 1 reply; 3+ messages in thread
From: hi @ 2026-09-06 13:44 UTC (permalink / raw)
To: akpm, david; +Cc: shuah, linux-mm, linux-kselftest, linux-kernel, jsavitz
[-- Attachment #1: Type: text/plain, Size: 1548 bytes --]
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>
---
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
(https://www.spaceship.com/business-email/?utm_source=def_email_sign&utm_medium=email&utm_campaign=def_email_sign)
[-- Attachment #2: Type: text/html, Size: 3742 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH RESEND] selftests/mm: Exit on invalid command-line options
2026-09-06 13:44 [PATCH] selftests/mm: Exit on invalid command-line options hi
@ 2026-09-06 13:54 ` Tianyi Chen
2026-09-07 11:47 ` David Hildenbrand (Arm)
0 siblings, 1 reply; 3+ messages in thread
From: Tianyi Chen @ 2026-09-06 13:54 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand
Cc: Tianyi Chen, Shuah Khan, linux-mm, linux-kselftest, linux-kernel,
Joel Savitz
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RESEND] selftests/mm: Exit on invalid command-line options
2026-09-06 13:54 ` [PATCH RESEND] " Tianyi Chen
@ 2026-09-07 11:47 ` David Hildenbrand (Arm)
0 siblings, 0 replies; 3+ messages in thread
From: David Hildenbrand (Arm) @ 2026-09-07 11:47 UTC (permalink / raw)
To: Tianyi Chen, Andrew Morton
Cc: Shuah Khan, linux-mm, linux-kselftest, linux-kernel, Joel Savitz
On 9/6/26 15:54, Tianyi Chen wrote:
> 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.
I wonder whether we also bail out on wrong/missing categories?
It's also interesting that we do the /proc/sys/kernel/yama/ptrace_scope stuff
even when not actually running the memfd_secret test.
--
Cheers,
David
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-07 11:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-06 13:44 [PATCH] selftests/mm: Exit on invalid command-line options hi
2026-09-06 13:54 ` [PATCH RESEND] " Tianyi Chen
2026-09-07 11:47 ` David Hildenbrand (Arm)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox