On Sun, Aug 23, 2026 at 11:41 PM Thomas Weißschuh
<[email protected]> wrote:
>
> On Sun, Aug 23, 2026 at 12:35:33PM +0000, Bill Wendling wrote:
> > Add a custom KUnit test suite 'stacktrace_counted_by' to verify that the
> > __counted_by_ptr annotation on the 'entries' field of 'struct stack_trace'
> > behaves correctly.
>
> The implementation of __counted_by_ptr should be tested by a dedicated 
> unittest
> for that feature. And I am fairly sure that already exists. It should not be
> tested in random subsystems.
>
I'm looking at `tools/unittests` and...what in the world is it
supposed to be testing? It looks like it's testing absolutely nothing
of substance. I assume you want there to be a test that runs and
produces a stack trace triggered by an invalid access, right? I'm
unable to find any tests in `tools/unittests` that do anything like
that...maybe I'm missing something?

-bw

> > The test verifies that 'max_entries' correctly limits and validates access
> > to 'entries' when CONFIG_ARCH_STACKWALK is not defined. If it is defined,
> > the test is cleanly skipped at runtime to prevent compile-time or runtime
> > failures due to 'struct stack_trace' being undefined on modern
> > architectures.
> >
> > Assisted-by: Gemini Next
> > Signed-off-by: Bill Wendling <[email protected]>
> > ---
> > Cc: Kees Cook <[email protected]>
> > Cc: "Gustavo A. R. Silva" <[email protected]>
> > Cc: Andrew Morton <[email protected]>
> > Cc: Brendan Higgins <[email protected]>
> > Cc: David Gow <[email protected]>
> > Cc: Rae Moar <[email protected]>
> > Cc: Ryota Sakamoto <[email protected]>
> > Cc: Kuan-Wei Chiu <[email protected]>
> > Cc: Pasha Tatashin <[email protected]>
> > Cc: Dmitry Antipov <[email protected]>
> > Cc: Petr Mladek <[email protected]>
> > Cc: Kir Chou <[email protected]>
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [email protected]
> > ---
> >  lib/Kconfig.debug            | 10 +++++++
> >  lib/kunit/.kunitconfig       |  1 +
> >  lib/tests/Makefile           |  1 +
> >  lib/tests/stacktrace_kunit.c | 51 ++++++++++++++++++++++++++++++++++++
> >  4 files changed, 63 insertions(+)
> >  create mode 100644 lib/tests/stacktrace_kunit.c
>
> (...)
>
> > diff --git a/lib/tests/stacktrace_kunit.c b/lib/tests/stacktrace_kunit.c
> > new file mode 100644
> > index 000000000000..7ec48edf84fe
> > --- /dev/null
> > +++ b/lib/tests/stacktrace_kunit.c
> > @@ -0,0 +1,51 @@
>
> (...)
>
> > +}
> > +#else
> > +static void test_stack_trace_counted_by(struct kunit *test)
> > +{
> > +     kunit_skip(test, "CONFIG_ARCH_STACKWALK is enabled, struct 
> > stack_trace is not defined");
>
> If the test requires a specific kconfig symbol, then depend on it in kconfig.
> Putting all of the code behind a single, giant ifdef is pointless.
>
> > +}
> > +#endif
>
> (...)

Reply via email to