> > ---
> > 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);
Though I'm still unsure whether this extra complexity is really worthwhile.