run_vmtests.sh can reach test setup after an invalid category selection, and its memfd_secret preparation can change ptrace_scope even when that category was not selected. These two patches address David's follow-up questions on the earlier getopts fix.
Patch 1 extends the getopts error handling to reject empty, whitespace-only and unknown category selections before setup. It uses the existing category list in usage() and normalizes separators, while preserving the default when -t is omitted and the existing environment-selection behavior. Patch 2 gates memfd_secret preparation on category selection and executable presence. It retains the existing behavior when memfd_secret is selected; it does not add configuration restoration or otherwise change that test. Changes in v2: - Rebase onto current mm-unstable. - Extend the original option-error patch with category validation. - Add a separate patch for the memfd_secret setup side effect. Focused validation: - Bash syntax and strict checkpatch passed. All 30 documented categories match the categories used by the script. - Parser checks cover omitted/default selections, empty environment values, explicit empty -t, invalid options/categories, whitespace-separated lists and command-line overrides of environment selections. - Twelve invalid-input cases and help were run through the full script in a KVM guest. Invalid inputs exited with status 1 before test setup. - The real mmap category's three programs and memfd_secret passed in an x86-64 KVM guest running Linux 7.3.0-rc1, including multi-category and environment-selected runs. - The guest kernel lacks Yama. A disposable file bind-mounted at the actual ptrace_scope path verified the shell's write condition: the old script writes for an unrelated selection, the new script does not, and selected executable memfd_secret retains the write. This checks script gating, not Yama policy enforcement. Missing-executable behavior was also checked. This was focused validation, not a run of the complete MM selftest suite. Previous submission: https://lore.kernel.org/r/[email protected] Review: https://lore.kernel.org/r/[email protected] Tianyi Chen (2): selftests/mm: Reject invalid test selections before running tests selftests/mm: Only prepare ptrace_scope when memfd_secret is selected tools/testing/selftests/mm/run_vmtests.sh | 29 +++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) -- 2.55.0

