Re: [PATCH 1/6] kunit: Introduce _NULL and _NOT_NULL macros

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

 



On Mon, Feb 7, 2022 at 11:09 AM Daniel Latypov <dlatypov@xxxxxxxxxx> wrote:
>
> On Mon, Feb 7, 2022 at 10:33 AM Ricardo Ribalda <ribalda@xxxxxxxxxxxx> wrote:
> >
> > Today, when we want to check if a pointer is NULL and not ERR we have
> > two options:
> >
> > EXPECT_TRUE(test, ptr == NULL);
> >
> > or
> >
> > EXPECT_PTR_NE(test, ptr, (struct mystruct *)NULL);
> >
> > Create a new set of macros that take care of NULL checks.
>
> I think we've usually had people do
>   KUNIT_EXPECT_FALSE(test, nullptr);
>
> I'm not personally against having an explicit NULL check, however.
>
> But if we want to continue with this, we'll want to rebase on top of
> https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/?h=kunit
> since a lot of this code has been deleted or refactored.
> E.g. see https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/tree/include/kunit/test.h?h=kunit

I forgot to mention, it'd also be a good idea to update the new
example test case:
https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/tree/lib/kunit/kunit-example-test.c?h=kunit#n76

e.g. just adding
  KUNIT_EXPECT_NULL(test, NULL);
with the rest of the pointer assertions



[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