All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org,
	Alexey Dobriyan <adobriyan@gmail.com>,
	"H.J. Lu" <hjl.tools@gmail.com>,
	Brendan Higgins <brendanhiggins@google.com>,
	David Gow <davidgow@google.com>, Rae Moar <rmoar@google.com>,
	linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com
Subject: KUnit file naming conventions (was Re: [GIT PULL] execve updates for v6.11-rc1)
Date: Tue, 16 Jul 2024 20:53:37 -0700	[thread overview]
Message-ID: <202407161505.A5AE57869@keescook> (raw)
In-Reply-To: <CAHk-=wgim6pNiGTBMhP8Kd3tsB7_JTAuvNJ=XYd3wPvvk=OHog@mail.gmail.com>

On Tue, Jul 16, 2024 at 01:10:41PM -0700, Linus Torvalds wrote:
> On Mon, 15 Jul 2024 at 09:21, Kees Cook <kees@kernel.org> wrote:
> >
> >  fs/exec.c                                   |  49 ++++++++--
> >  fs/exec_test.c                              | 141 ++++++++++++++++++++++++++++
> 
> I've pulled this, but *PLEASE* don't do this.
> 
> This screws up my workflow of just using tab-completion for filenames.
> As a result, I absolutely abhor anybody who uses the same base-name
> for different things.
> 
> No, this is not the first time it happens, and it won't be the last.
> And we had that same horrific pattern for fs/binfmt_elf_test.c from
> before, and I didn't notice because it's not a core file to me, and I
> seldom actually edit it.
> 
> I would suggest that people use the patterns from lib/, which is
> admittedly a bit schizophrenic in that you can either use
> "lib/kunit/*.c" (probably preferred) or "lib/test_xyz.c".
> 
> (Other subsystems use a "tests" subdirectory, so we do have a lot of
> different ways to deal with this).
> 
> Any of those models will keep the unit testing parts clearly separate,
> and not mess up basic command line workflows.
> 
> But do *not* use this "*_test.c" naming model. It's the worst of all
> possible worlds.
> 
> Please?

Oh, sure, no problem! I have no attachment to this convention at all;
I was trying to follow the Kunit docs:
https://docs.kernel.org/dev-tools/kunit/style.html#test-file-and-module-names

If I look at the existing naming, it's pretty scattered:

$ git grep '^static struct kunit_suite\b' | cut -d: -f1 | sort -u

/test/*		 7
/tests/*	47
*-test.[ch]	27
*_test.[ch]	27
test-*.c	 1
test_*.c	10
*-kunit.c	 1
*_kunit.c	17
kunit-*.c	 2
kunit_*.c	 1

Should we go with "put it all under a 'tests' subdirectory" ?

So for fs/exec_test.c and fs/binfmt_elf_test.c, perhaps fs/tests/exec.c
and fs/tests/binfmt_elf.c respectively?

And for the lib/*_kunit.c files, use lib/tests/*.c ?

Then we can update the docs, etc.

-- 
Kees Cook

  reply	other threads:[~2024-07-17  3:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-15 16:21 [GIT PULL] execve updates for v6.11-rc1 Kees Cook
2024-07-16 20:10 ` Linus Torvalds
2024-07-17  3:53   ` Kees Cook [this message]
2024-07-17  6:28     ` KUnit file naming conventions (was Re: [GIT PULL] execve updates for v6.11-rc1) David Gow
2024-07-17 16:49       ` Kees Cook
2024-07-18  6:02         ` David Gow
2024-07-16 21:43 ` [GIT PULL] execve updates for v6.11-rc1 pr-tracker-bot

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=202407161505.A5AE57869@keescook \
    --to=kees@kernel.org \
    --cc=adobriyan@gmail.com \
    --cc=brendanhiggins@google.com \
    --cc=davidgow@google.com \
    --cc=hjl.tools@gmail.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=rmoar@google.com \
    --cc=torvalds@linux-foundation.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.