From: Petr Mladek <pmladek@suse.com>
To: Tamir Duberstein <tamird@gmail.com>
Cc: Arpitha Raghunandan <98.arpi@gmail.com>,
David Gow <davidgow@google.com>,
Steven Rostedt <rostedt@goodmis.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Andrew Morton <akpm@linux-foundation.org>,
Shuah Khan <shuah@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
Naveen N Rao <naveen@kernel.org>,
Brendan Higgins <brendan.higgins@linux.dev>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-doc@vger.kernel.org, linux-m68k@lists.linux-m68k.org,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v5 1/3] printf: convert self-test to KUnit
Date: Fri, 7 Mar 2025 17:00:58 +0100 [thread overview]
Message-ID: <Z8sYOm4qovtdOSI7@pathway.suse.cz> (raw)
In-Reply-To: <CAJ-ks9nFSzRXFauavzSWhvhr2Rou7qqkWi_LZ=4e1Tyr4_bn3g@mail.gmail.com>
On Thu 2025-03-06 09:25:43, Tamir Duberstein wrote:
> On Thu, Mar 6, 2025 at 7:25 AM Petr Mladek <pmladek@suse.com> wrote:
> >
> > On Fri 2025-02-21 15:34:30, Tamir Duberstein wrote:
> > > Convert the printf() self-test to a KUnit test.
> > >
> > > In the interest of keeping the patch reasonably-sized this doesn't
> > > refactor the tests into proper parameterized tests - it's all one big
> > > test case.
> > >
> > > --- a/lib/test_printf.c
> > > +++ b/lib/tests/printf_kunit.c
> > > @@ -57,52 +58,50 @@ do_test(int bufsize, const char *expect, int elen,
> > > va_end(aq);
> > >
> > > if (ret != elen) {
> > > - pr_warn("vsnprintf(buf, %d, \"%s\", ...) returned %d, expected %d\n",
> > > + tc_fail("vsnprintf(buf, %d, \"%s\", ...) returned %d, expected %d",
> >
> > 1. It looks a bit strange that the 1st patch replaces pr_warn() with
> > tc_fail() which hides KUNIT_FAIL().
> >
> > And the 2nd patch replaces tc_fail() with KUNIT_FAIL().
> >
> > It looks like a non-necessary churn.
> >
> > It would be better to avoid the temporary "tc_fail" and swith to
> > KUNIT_FAIL() already in this patch.
> >
> > I did not find any comment about this in the earier versions of the
> > patchset.
> >
> > Is it just a result of the evolution of the patchset or
> > is there any motivation for this?
>
> The motivation was to keep the width of the macro the same in this
> first patch for ease of review, particularly in the 7 instances where
> the invocation wraps to a second line. If you prefer I go straight to
> KUNIT_FAIL, I can make that change.
I see. It might have been useful when the patch removed the trailing '\n'.
But you are going to add it back. So there won't be any hidden change.
So I would prefer to go straight to KUNIT_FAIL().
> > > @@ -842,13 +836,15 @@ test_pointer(void)
> > > fourcc_pointer();
> > > }
> > >
> > > -static void __init selftest(void)
> > > +static void printf_test(struct kunit *test)
> > > {
> > > alloced_buffer = kmalloc(BUF_SIZE + 2*PAD_SIZE, GFP_KERNEL);
> > > if (!alloced_buffer)
> > > return;
> >
> > I would use here:
> >
> > KUNIT_ASSERT_NOT_NULL(test, alloced_buffer);
> >
> > And move the same change for the other kmalloc() location from
> > the 2nd patch.
>
> I didn't do that here because I was trying to keep this patch as small
> as possible, and I wrote that in the commit message.
>
> As for using KUNIT_ASSERT_NOT_NULL here, that would have to change
> back to an error return in the 2nd patch because this code moves into
> `suite_init`, which is called with `struct kunit_suite` rather than
> `struct kunit_test`, and KUnit assertion macros do not work with the
> former (and for good reason, because failures in suite setup cannot be
> attributed to a particular test case).
I see. KUNIT_ASSERT_NOT_NULL() can't be used in the .suite_exit() callback.
> So I'd prefer to leave this as is.
I agree to leave this as is.
Best Regards,
Petr
next prev parent reply other threads:[~2025-03-07 16:01 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-21 20:34 [PATCH v5 0/3] printf: convert self-test to KUnit Tamir Duberstein
2025-02-21 20:34 ` [PATCH v5 1/3] " Tamir Duberstein
2025-03-06 12:25 ` Petr Mladek
2025-03-06 14:25 ` Tamir Duberstein
2025-03-06 14:41 ` Tamir Duberstein
2025-03-07 15:55 ` Petr Mladek
2025-03-07 16:30 ` Tamir Duberstein
2025-03-07 16:00 ` Petr Mladek [this message]
2025-03-07 16:27 ` Tamir Duberstein
2025-02-21 20:34 ` [PATCH v5 2/3] printf: break kunit into test cases Tamir Duberstein
2025-03-06 16:44 ` Petr Mladek
2025-03-06 17:28 ` Tamir Duberstein
2025-03-07 16:18 ` crng init: was: " Petr Mladek
2025-03-07 16:25 ` Tamir Duberstein
2025-02-21 20:34 ` [PATCH v5 3/3] printf: implicate test line in failure messages Tamir Duberstein
2025-03-07 16:23 ` Petr Mladek
2025-03-07 16:24 ` Tamir Duberstein
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=Z8sYOm4qovtdOSI7@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=98.arpi@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=brendan.higgins@linux.dev \
--cc=christophe.leroy@csgroup.eu \
--cc=corbet@lwn.net \
--cc=davidgow@google.com \
--cc=geert@linux-m68k.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.org \
--cc=linux@rasmusvillemoes.dk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=naveen@kernel.org \
--cc=npiggin@gmail.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=shuah@kernel.org \
--cc=tamird@gmail.com \
/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).