All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hongfu Li <hongfu.li@linux.dev>
To: sj@kernel.org
Cc: akpm@linux-foundation.org, david@kernel.org, hongfu.li@linux.dev,
	liam@infradead.org, lihongfu@kylinos.cn,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-mm@kvack.org, ljs@kernel.org, mhocko@suse.com,
	rppt@kernel.org, shuah@kernel.org, surenb@google.com,
	vbabka@kernel.org
Subject: Re: [PATCH v2] selftests/mm: Drop duplicate test_seal_mprotect_two_vma_with_gap() call
Date: Fri,  7 Aug 2026 15:15:33 +0800	[thread overview]
Message-ID: <20260807071533.48130-1-hongfu.li@linux.dev> (raw)
In-Reply-To: <20260807003126.81629-1-sj@kernel.org>

> > ---
> > 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.

  reply	other threads:[~2026-08-07  7:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06  3:08 [PATCH v2] selftests/mm: Drop duplicate test_seal_mprotect_two_vma_with_gap() call Hongfu Li
2026-08-07  0:31 ` SJ Park
2026-08-07  7:15   ` Hongfu Li [this message]
2026-08-08  0:15     ` SJ Park
2026-08-07  6:00 ` Anshuman Khandual

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=20260807071533.48130-1-hongfu.li@linux.dev \
    --to=hongfu.li@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=liam@infradead.org \
    --cc=lihongfu@kylinos.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=rppt@kernel.org \
    --cc=shuah@kernel.org \
    --cc=sj@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.