Re: [PATCH v2] selftests/mm: Drop duplicate test_seal_mprotect_two_vma_with_gap() call
SJ Park <[email protected]>
| Newsgroups | org.kernel.vger.linux-kselftest,org.kernel.vger.linux-kernel,org.kvack.linux-mm |
|---|---|
| Message-ID | <[email protected]> |
On Fri, 7 Aug 2026 15:15:33 +0800 Hongfu Li <[email protected]> wrote: > > > --- > > > v2: > > > - update ksft_set_plan(88) to 87 to match the actual number of tests > > > after removing the duplicate call. > > > > I wonder if there could be an automated way for this. Obviously not a question > > to the author but just my loud thought. > > Glad you brought this up, I totally agree with your thought. > > Something like the below refactor could achieve that automation: > > +typedef void (*test_fn)(void); > +typedef void (*test_fn_seal)(bool seal); > + > +static const struct { > + test_fn_seal fn; > + bool seal; > +} tests_seal[] = { > + { test_seal_mprotect, false }, > + { test_seal_mprotect, true }, > ... > +}; > + > +static const test_fn tests[] = { > + test_seal_addseal, > + test_seal_unmapped_start, > ... > +}; > + > + > int main(void) > { > ... > - ksft_set_plan(87); > + ksft_set_plan(ARRAY_SIZE(tests) + ARRAY_SIZE(tests_seal)); > + for (size_t i = 0; i < ARRAY_SIZE(tests); i++) > + tests[i](); > + for (size_t i = 0; i < ARRAY_SIZE(tests_seal); i++) > + tests_seal[i].fn(tests_seal[i].seal); Thank you for sharing your great idea. > > Though I'm still unsure whether this extra complexity is really worthwhile. Agreed. I believe it is good to have this as is for now. If we have to add such automation, I think kselftest framework is a better place to change, than each test. Thanks, SJ