From: David Gow <david@davidgow.net>
To: Albert Esteve <aesteve@redhat.com>, Arnd Bergmann <arnd@arndb.de>,
Brendan Higgins <brendan.higgins@linux.dev>,
Rae Moar <raemoar63@gmail.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com,
dri-devel@lists.freedesktop.org, workflows@vger.kernel.org,
linux-doc@vger.kernel.org, peterz@infradead.org,
Guenter Roeck <linux@roeck-us.net>,
Linux Kernel Functional Testing <lkft@linaro.org>,
Dan Carpenter <dan.carpenter@linaro.org>,
Alessandro Carminati <acarmina@redhat.com>,
Kees Cook <kees@kernel.org>
Subject: Re: [PATCH v7 5/5] kunit: Add documentation for warning backtrace suppression API
Date: Wed, 22 Apr 2026 20:20:26 +0800 [thread overview]
Message-ID: <0bd3f863-207d-4994-92cb-ec9999c0bc1b@davidgow.net> (raw)
In-Reply-To: <20260420-kunit_add_support-v7-5-e8bc6e0f70de@redhat.com>
Le 20/04/2026 à 8:28 PM, Albert Esteve a écrit :
> From: Guenter Roeck <linux@roeck-us.net>
>
> Document API functions for suppressing warning backtraces.
>
> Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
> Acked-by: Dan Carpenter <dan.carpenter@linaro.org>
> Reviewed-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> Reviewed-by: David Gow <davidgow@google.com>
> Signed-off-by: Alessandro Carminati <acarmina@redhat.com>
> Signed-off-by: Albert Esteve <aesteve@redhat.com>
> ---
Thanks -- it's always good to have documentation.
Apart from one note below, this looks good to me.
Reviewed-by: David Gow <david@davidgow.net>
Cheers,
-- David
> Documentation/dev-tools/kunit/usage.rst | 30 +++++++++++++++++++++++++++++-
> 1 file changed, 29 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/dev-tools/kunit/usage.rst b/Documentation/dev-tools/kunit/usage.rst
> index ebd06f5ea4550..76e85412f240e 100644
> --- a/Documentation/dev-tools/kunit/usage.rst
> +++ b/Documentation/dev-tools/kunit/usage.rst
> @@ -157,6 +157,34 @@ Alternatively, one can take full control over the error message by using
> if (some_setup_function())
> KUNIT_FAIL(test, "Failed to setup thing for testing");
>
> +Suppressing warning backtraces
> +------------------------------
> +
> +Some unit tests trigger warning backtraces either intentionally or as side
> +effect. Such backtraces are normally undesirable since they distract from
> +the actual test and may result in the impression that there is a problem.
> +
> +Such backtraces can be suppressed with **task scope suppression**: while
> +``START`` / ``END`` is active on the current task, the backtrace and stack
> +dump from warnings on that task are suppressed. Wrap the call from your test
> +in that window, like shown in the following code.
> +
> +.. code-block:: c
> +
> + static void some_test(struct kunit *test)
> + {
> + KUNIT_START_SUPPRESSED_WARNING(test);
> + trigger_backtrace();
> + KUNIT_END_SUPPRESSED_WARNING(test);
> + }
> +
> +``KUNIT_SUPPRESSED_WARNING_COUNT()`` returns the number of suppressed backtraces.
> +If the suppressed backtrace was triggered on purpose, this can be used to check
> +if the backtrace was actually triggered.
> +
> +.. code-block:: c
> +
> + KUNIT_EXPECT_EQ(test, KUNIT_SUPPRESSED_WARNING_COUNT(), 1);
It might be worth noting that all of these must be in the same function,
and the KUNIT_START_SUPPRESSED_WARNING() must be first. (And, in
addition, there can't be more than one START/END pair per-function).
Of course, if the implementation is changed, that wouldn't be necessary. :-)
>
> Test Suites
> ~~~~~~~~~~~
> @@ -1211,4 +1239,4 @@ For example:
> dev_managed_string = devm_kstrdup(fake_device, "Hello, World!");
>
> // Everything is cleaned up automatically when the test ends.
> - }
> \ No newline at end of file
> + }
>
prev parent reply other threads:[~2026-04-22 12:24 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 12:28 [PATCH v7 0/5] kunit: Add support for suppressing warning backtraces Albert Esteve
2026-04-20 12:28 ` [PATCH v7 1/5] bug/kunit: Core " Albert Esteve
2026-04-20 14:39 ` Peter Zijlstra
2026-04-21 8:22 ` Albert Esteve
2026-04-20 14:45 ` Peter Zijlstra
2026-04-21 8:29 ` Albert Esteve
2026-04-22 12:19 ` David Gow
2026-04-20 12:28 ` [PATCH v7 2/5] bug/kunit: Reduce runtime impact of warning backtrace suppression Albert Esteve
2026-04-20 14:44 ` Peter Zijlstra
2026-04-21 8:41 ` Albert Esteve
2026-04-22 12:19 ` David Gow
2026-04-20 12:28 ` [PATCH v7 3/5] kunit: Add backtrace suppression self-tests Albert Esteve
2026-04-22 12:20 ` David Gow
2026-04-20 12:28 ` [PATCH v7 4/5] drm: Suppress intentional warning backtraces in scaling unit tests Albert Esteve
2026-04-20 14:47 ` Peter Zijlstra
2026-04-21 8:49 ` Albert Esteve
2026-04-21 11:50 ` Jani Nikula
2026-04-22 12:20 ` David Gow
2026-04-20 12:28 ` [PATCH v7 5/5] kunit: Add documentation for warning backtrace suppression API Albert Esteve
2026-04-22 12:20 ` David Gow [this message]
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=0bd3f863-207d-4994-92cb-ec9999c0bc1b@davidgow.net \
--to=david@davidgow.net \
--cc=acarmina@redhat.com \
--cc=aesteve@redhat.com \
--cc=airlied@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=brendan.higgins@linux.dev \
--cc=corbet@lwn.net \
--cc=dan.carpenter@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=kees@kernel.org \
--cc=kunit-dev@googlegroups.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=lkft@linaro.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=peterz@infradead.org \
--cc=raemoar63@gmail.com \
--cc=simona@ffwll.ch \
--cc=skhan@linuxfoundation.org \
--cc=tzimmermann@suse.de \
--cc=workflows@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox