Re: [PATCH v6 1/3] kunit: Introduce KUNIT_EXPECT_MEMEQ and KUNIT_EXPECT_MEMNEQ macros

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

 



On Tue, Oct 18, 2022 at 12:06 PM Maíra Canal <mairacanal@xxxxxxxxxx> wrote:
> diff --git a/include/kunit/test.h b/include/kunit/test.h
> index b1ab6b32216d..cde97dc4eed5 100644
> --- a/include/kunit/test.h
> +++ b/include/kunit/test.h
> @@ -658,6 +658,39 @@ do {                                                                              \
>                       ##__VA_ARGS__);                                          \
>  } while (0)
>
> +#define KUNIT_MEM_ASSERTION(test,                                             \
> +                           assert_type,                                       \
> +                           left,                                              \
> +                           op,                                                \
> +                           right,                                             \
> +                           size,                                              \
> +                           fmt,                                               \
> +                           ...)                                               \
> +do {                                                                          \
> +       const void *__left = (left);                                           \
> +       const void *__right = (right);                                         \
> +       const size_t __size = (size);                                          \
> +       static const struct kunit_binary_assert_text __text = {                \
> +               .operation = #op,                                              \
> +               .left_text = #left,                                            \
> +               .right_text = #right,                                          \
> +       };                                                                     \
> +                                                                              \
> +       if (likely(memcmp(__left, __right, __size) op 0))                      \
> +               break;                                                         \
> +                                                                              \
> +       _KUNIT_FAILED(test,                                                    \
> +                     assert_type,                                             \
> +                     kunit_mem_assert,                                        \
> +                     kunit_mem_assert_format,                                 \
> +                     KUNIT_INIT_MEM_ASSERT_STRUCT(&__text,                    \
> +                                                  __left,                     \
> +                                                  __right,                    \
> +                                                  __size),                    \
> +                     fmt,                                                     \
> +                     ##__VA_ARGS__);                                          \
> +} while (0)
> +

I think this should have been the only real change we needed to make
(to resolve the merge conflict I created).
Looks good to me. I think this series is still good to go.

Sorry for changing the assertion internals out from under you!

Daniel




[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