From: David Gow <davidgow@google.com>
To: Daniel Latypov <dlatypov@google.com>
Cc: Brendan Higgins <brendanhiggins@google.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
KUnit Development <kunit-dev@googlegroups.com>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@vger.kernel.org>,
Shuah Khan <skhan@linuxfoundation.org>,
"Theodore Ts'o" <tytso@mit.edu>
Subject: Re: [PATCH] kunit: tool: make --kunitconfig accept dirs, add lib/kunit fragment
Date: Tue, 23 Feb 2021 13:38:27 +0800 [thread overview]
Message-ID: <CABVgOSk0G7xzoOjnz-oReDER7_e6V+j6fH63FdN8O40_8fNzGA@mail.gmail.com> (raw)
In-Reply-To: <20210222225241.201145-1-dlatypov@google.com>
On Tue, Feb 23, 2021 at 6:52 AM Daniel Latypov <dlatypov@google.com> wrote:
>
> TL;DR
> $ ./tools/testing/kunit/kunit.py run --kunitconfig=lib/kunit
>
> Per suggestion from Ted [1], we can reduce the amount of typing by
> assuming a convention that these files are named '.kunitconfig'.
>
> In the case of [1], we now have
> $ ./tools/testing/kunit/kunit.py run --kunitconfig=fs/ext4
>
> Also add in such a fragment for kunit itself so we can give that as an
> example more close to home (and thus less likely to be accidentally
> broken).
>
> [1] https://lore.kernel.org/linux-ext4/YCNF4yP1dB97zzwD@mit.edu/
>
> Signed-off-by: Daniel Latypov <dlatypov@google.com>
> ---
Thanks! I really like this.
I'd assumed we'd check if the path exists, and fall back to appending
".kunitconfig", but checking if it's a directory is better.
I tried this out with all the different combinations I could think of,
and it works well.
Reviewed-by: David Gow <davidgow@google.com>
Cheers,
-- David
> lib/kunit/.kunitconfig | 3 +++
> tools/testing/kunit/kunit.py | 4 +++-
> tools/testing/kunit/kunit_kernel.py | 2 ++
> tools/testing/kunit/kunit_tool_test.py | 6 ++++++
> 4 files changed, 14 insertions(+), 1 deletion(-)
> create mode 100644 lib/kunit/.kunitconfig
>
> diff --git a/lib/kunit/.kunitconfig b/lib/kunit/.kunitconfig
> new file mode 100644
> index 000000000000..9235b7d42d38
> --- /dev/null
> +++ b/lib/kunit/.kunitconfig
> @@ -0,0 +1,3 @@
> +CONFIG_KUNIT=y
> +CONFIG_KUNIT_TEST=y
> +CONFIG_KUNIT_EXAMPLE_TEST=y
> diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py
> index d5144fcb03ac..5da8fb3762f9 100755
> --- a/tools/testing/kunit/kunit.py
> +++ b/tools/testing/kunit/kunit.py
> @@ -184,7 +184,9 @@ def add_common_opts(parser) -> None:
> help='Run all KUnit tests through allyesconfig',
> action='store_true')
> parser.add_argument('--kunitconfig',
> - help='Path to Kconfig fragment that enables KUnit tests',
> + help='Path to Kconfig fragment that enables KUnit tests.'
> + ' If given a directory, (e.g. lib/kunit), "/.kunitconfig" '
> + 'will get automatically appended.',
> metavar='kunitconfig')
>
> def add_build_opts(parser) -> None:
> diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py
> index f309a33256cd..89a7d4024e87 100644
> --- a/tools/testing/kunit/kunit_kernel.py
> +++ b/tools/testing/kunit/kunit_kernel.py
> @@ -132,6 +132,8 @@ class LinuxSourceTree(object):
> return
>
> if kunitconfig_path:
> + if os.path.isdir(kunitconfig_path):
> + kunitconfig_path = os.path.join(kunitconfig_path, KUNITCONFIG_PATH)
> if not os.path.exists(kunitconfig_path):
> raise ConfigError(f'Specified kunitconfig ({kunitconfig_path}) does not exist')
> else:
> diff --git a/tools/testing/kunit/kunit_tool_test.py b/tools/testing/kunit/kunit_tool_test.py
> index 1ad3049e9069..2e809dd956a7 100755
> --- a/tools/testing/kunit/kunit_tool_test.py
> +++ b/tools/testing/kunit/kunit_tool_test.py
> @@ -251,6 +251,12 @@ class LinuxSourceTreeTest(unittest.TestCase):
> with tempfile.NamedTemporaryFile('wt') as kunitconfig:
> tree = kunit_kernel.LinuxSourceTree('', kunitconfig_path=kunitconfig.name)
>
> + def test_dir_kunitconfig(self):
> + with tempfile.TemporaryDirectory('') as dir:
> + with open(os.path.join(dir, '.kunitconfig'), 'w') as f:
> + pass
> + tree = kunit_kernel.LinuxSourceTree('', kunitconfig_path=dir)
> +
> # TODO: add more test cases.
>
>
>
> base-commit: b12b47249688915e987a9a2a393b522f86f6b7ab
> --
> 2.30.0.617.g56c4b15f3c-goog
>
next prev parent reply other threads:[~2021-02-23 5:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-22 22:52 [PATCH] kunit: tool: make --kunitconfig accept dirs, add lib/kunit fragment Daniel Latypov
2021-02-23 5:38 ` David Gow [this message]
2021-04-02 9:32 ` Brendan Higgins
2021-04-02 18:00 ` Shuah Khan
2021-04-02 19:27 ` Daniel Latypov
2021-04-02 19:31 ` Shuah Khan
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=CABVgOSk0G7xzoOjnz-oReDER7_e6V+j6fH63FdN8O40_8fNzGA@mail.gmail.com \
--to=davidgow@google.com \
--cc=brendanhiggins@google.com \
--cc=dlatypov@google.com \
--cc=kunit-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=tytso@mit.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).