From: Albert Esteve <aesteve@redhat.com>
To: Arnd Bergmann <arnd@arndb.de>,
Brendan Higgins <brendan.higgins@linux.dev>,
David Gow <david@davidgow.net>, 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>
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, Guenter Roeck <linux@roeck-us.net>,
Linux Kernel Functional Testing <lkft@linaro.org>,
Dan Carpenter <dan.carpenter@linaro.org>,
Alessandro Carminati <acarmina@redhat.com>,
Albert Esteve <aesteve@redhat.com>, Kees Cook <kees@kernel.org>,
David Gow <david@davidgow.net>
Subject: [PATCH v6 5/5] kunit: Add documentation for warning backtrace suppression API
Date: Tue, 17 Mar 2026 10:24:45 +0100 [thread overview]
Message-ID: <20260317-kunit_add_support-v6-5-dd22aeb3fe5d@redhat.com> (raw)
In-Reply-To: <20260317-kunit_add_support-v6-0-dd22aeb3fe5d@redhat.com>
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>
---
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..f1f8e2619d2d6 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. To suppress a backtrace in some_function(),
+use the following code.
+
+.. code-block:: c
+
+ static void some_test(struct kunit *test)
+ {
+ DEFINE_SUPPRESSED_WARNING(some_function);
+
+ KUNIT_START_SUPPRESSED_WARNING(some_function);
+ trigger_backtrace();
+ KUNIT_END_SUPPRESSED_WARNING(some_function);
+ }
+
+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, SUPPRESSED_WARNING_COUNT(some_function), 1);
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
+ }
--
2.52.0
next prev parent reply other threads:[~2026-03-17 9:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-17 9:24 [PATCH v6 0/5] kunit: Add support for suppressing warning backtraces Albert Esteve
2026-03-17 9:24 ` [PATCH v6 1/5] bug/kunit: Core " Albert Esteve
2026-03-17 9:24 ` [PATCH v6 2/5] bug/kunit: Suppressing warning backtraces reduced impact on WARN*() sites Albert Esteve
2026-03-17 9:24 ` [PATCH v6 3/5] Add unit tests to verify that warning backtrace suppression works Albert Esteve
2026-03-17 9:24 ` [PATCH v6 4/5] drm: Suppress intentional warning backtraces in scaling unit tests Albert Esteve
2026-03-17 9:24 ` Albert Esteve [this message]
2026-03-17 10:03 ` [PATCH v6 0/5] kunit: Add support for suppressing warning backtraces Dan Carpenter
2026-03-17 14:55 ` Guenter Roeck
2026-03-17 11:20 ` Vlastimil Babka (SUSE)
2026-03-17 11:30 ` Peter Zijlstra
2026-03-17 15:02 ` Guenter Roeck
2026-03-18 9:25 ` Albert Esteve
2026-03-18 11:51 ` Peter Zijlstra
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=20260317-kunit_add_support-v6-5-dd22aeb3fe5d@redhat.com \
--to=aesteve@redhat.com \
--cc=acarmina@redhat.com \
--cc=airlied@gmail.com \
--cc=arnd@arndb.de \
--cc=brendan.higgins@linux.dev \
--cc=corbet@lwn.net \
--cc=dan.carpenter@linaro.org \
--cc=david@davidgow.net \
--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=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