Re: [PATCH v4 3/3] printf: implicate test line in failure messages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 19, 2025 at 3:41 PM Rasmus Villemoes
<linux@xxxxxxxxxxxxxxxxxx> wrote:
>
> On Fri, 14 Feb 2025 at 22:53, Tamir Duberstein <tamird@xxxxxxxxx> wrote:
> >
> > This improves the failure output by pointing to the failing line at the
> > top level of the test, e.g.:
> >       # test_number: EXPECTATION FAILED at lib/printf_kunit.c:103
> >   lib/printf_kunit.c:167: vsnprintf(buf, 256, "%#-12x", ...) wrote '0x1234abcd  ', expected '0x1234abce  '
> >       # test_number: EXPECTATION FAILED at lib/printf_kunit.c:142
> >   lib/printf_kunit.c:167: kvasprintf(..., "%#-12x", ...) returned '0x1234abcd  ', expected '0x1234abce  '
> >
>
> Actually, I'm not sure that is an improvement as-is, with the two
> different line numbers being printed. It takes some thought to
> recognize which one is relevant and which one is not.

They're both relevant -- `do_test` does a bunch of checks, so you want
to know which particular check failed, but also which invocation at
the top level resulted in that check failing.

> Can't we have a variant of KUNIT_FAIL that allows one to pass the
> file/line info when the caller has better info than the location of
> the KUNIT_FAIL itself?
>
> >  static void __printf(5, 0)
> > -do_test(struct kunit *kunittest, int bufsize, const char *expect, int elen,
> > -       const char *fmt, va_list ap)
> > +do_test(struct kunit *kunittest, const char *file, const int line, int bufsize, const char *expect,
> > +       int elen, const char *fmt, va_list ap)
>
> This can't be right, the __printf attribute must be updated accordingly.

Good catch. Oddly I'm not able to reproduce any compiler complaints
here, even with the attribute completely removed.





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux