All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Documentation: kunit: Clarify test filter format
@ 2024-03-28 14:20 Brendan Jackman
  2024-03-28 18:27 ` Daniel Latypov
  0 siblings, 1 reply; 3+ messages in thread
From: Brendan Jackman @ 2024-03-28 14:20 UTC (permalink / raw)
  To: linux-kselftest, kunit-dev, linux-doc, linux-kernel
  Cc: Brendan Higgins, davidgow, rmoar, corbet, Brendan Jackman

It seems obvious once you know, but at first I didn't realise that the
suite name is part of this format. Document it and add example.

Signed-off-by: Brendan Jackman <jackmanb@google.com>
---
 Documentation/dev-tools/kunit/run_wrapper.rst | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/Documentation/dev-tools/kunit/run_wrapper.rst b/Documentation/dev-tools/kunit/run_wrapper.rst
index 19ddf5e07013..e75a5fc05814 100644
--- a/Documentation/dev-tools/kunit/run_wrapper.rst
+++ b/Documentation/dev-tools/kunit/run_wrapper.rst
@@ -156,13 +156,20 @@ Filtering tests
 ===============
 
 By passing a bash style glob filter to the ``exec`` or ``run``
-commands, we can run a subset of the tests built into a kernel . For
+commands, we can run a subset of the tests built into a kernel,
+identified by a string like ``$suite_name.$test_name``. For
 example: if we only want to run KUnit resource tests, use:
 
 .. code-block::
 
 	./tools/testing/kunit/kunit.py run 'kunit-resource*'
 
+Or to run just one specific test from that suite:
+
+.. code-block::
+
+	./tools/testing/kunit/kunit.py run 'kunit-resource-test.kunit_resource_test_init_resources'
+
 This uses the standard glob format with wildcard characters.
 
 .. _kunit-on-qemu:
-- 
2.44.0.396.g6e790dbe36-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Documentation: kunit: Clarify test filter format
  2024-03-28 14:20 [PATCH] Documentation: kunit: Clarify test filter format Brendan Jackman
@ 2024-03-28 18:27 ` Daniel Latypov
  2024-04-02  9:52   ` Brendan Jackman
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Latypov @ 2024-03-28 18:27 UTC (permalink / raw)
  To: Brendan Jackman
  Cc: linux-kselftest, kunit-dev, linux-doc, linux-kernel,
	Brendan Higgins, davidgow, rmoar, corbet

On Thu, Mar 28, 2024 at 7:20 AM 'Brendan Jackman' via KUnit
Development <kunit-dev@googlegroups.com> wrote:
>
> It seems obvious once you know, but at first I didn't realise that the
> suite name is part of this format. Document it and add example.
>
> Signed-off-by: Brendan Jackman <jackmanb@google.com>
> ---
>  Documentation/dev-tools/kunit/run_wrapper.rst | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/dev-tools/kunit/run_wrapper.rst b/Documentation/dev-tools/kunit/run_wrapper.rst
> index 19ddf5e07013..e75a5fc05814 100644
> --- a/Documentation/dev-tools/kunit/run_wrapper.rst
> +++ b/Documentation/dev-tools/kunit/run_wrapper.rst
> @@ -156,13 +156,20 @@ Filtering tests
>  ===============
>
>  By passing a bash style glob filter to the ``exec`` or ``run``
> -commands, we can run a subset of the tests built into a kernel . For
> +commands, we can run a subset of the tests built into a kernel,
> +identified by a string like ``$suite_name.$test_name``. For

Apologies for the overly terse docs, that's my fault :)
I'm wondering if we can further improve it while we're here.

Note, the format for the glob is: $suite_name[.$test_name].

This current wording and examples (before and after this change) might
make the user think otherwise, i.e. that it works like
  effective_name = suite_name + '.' + test_name
  return glob_matches(effective_name, filter_glob)

E.g. given a test name like `suite.test_name` and glob='suite*name'
they might expect it to match, but it does *not*.

The logic actually works like:
  suite_glob, test_glob = split(filter_glob)
  if not_glob_matches(suite_name, suite_glob):
     return False
  if test_glob and not glob_matches(test_name, test_glob):
     return False
  return True

Perhaps expanding the list of examples to cover more of the edge cases
could help get the right intuition?

E.g. perhaps these:
  kunit.py run <suite_name>  # runs all tests in a specific suite
  kunit.py run <suite_name>.<test_name>  # run a specific test

  kunit.py run suite_prefix*  # what the current example shows
  kunit.py run *.*test_suffix  # matches all suites, only tests w/ a
certain suffix
  kunit.py run suite_prefix*.*test_suffix # combined version of above

Thoughts?

Thanks,
Daniel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Documentation: kunit: Clarify test filter format
  2024-03-28 18:27 ` Daniel Latypov
@ 2024-04-02  9:52   ` Brendan Jackman
  0 siblings, 0 replies; 3+ messages in thread
From: Brendan Jackman @ 2024-04-02  9:52 UTC (permalink / raw)
  To: Daniel Latypov
  Cc: linux-kselftest, kunit-dev, linux-doc, linux-kernel,
	Brendan Higgins, davidgow, rmoar, corbet

On Thu, 28 Mar 2024 at 19:27, Daniel Latypov <dlatypov@google.com> wrote:
> This current wording and examples (before and after this change) might
> make the user think otherwise, i.e. that it works like
>   effective_name = suite_name + '.' + test_name
>   return glob_matches(effective_name, filter_glob)
>
> E.g. given a test name like `suite.test_name` and glob='suite*name'
> they might expect it to match, but it does *not*.
>
> The logic actually works like:
>   suite_glob, test_glob = split(filter_glob)
>   if not_glob_matches(suite_name, suite_glob):
>      return False
>   if test_glob and not glob_matches(test_name, test_glob):
>      return False
>   return True
>
> Perhaps expanding the list of examples to cover more of the edge cases
> could help get the right intuition?
>
> E.g. perhaps these:
>   kunit.py run <suite_name>  # runs all tests in a specific suite
>   kunit.py run <suite_name>.<test_name>  # run a specific test
>
>   kunit.py run suite_prefix*  # what the current example shows
>   kunit.py run *.*test_suffix  # matches all suites, only tests w/ a
> certain suffix
>   kunit.py run suite_prefix*.*test_suffix # combined version of above
>
> Thoughts?

Thanks yeah, good point. The result is pretty verbose but it doesn't
create much cognitive load for the reader so might as well just be
really explicit. v2 incoming if `make htmldocs` ever finishes....

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-02  9:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-28 14:20 [PATCH] Documentation: kunit: Clarify test filter format Brendan Jackman
2024-03-28 18:27 ` Daniel Latypov
2024-04-02  9:52   ` Brendan Jackman

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.