lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABVgOSkm349TgYProFFghSrRomU4ZLCAqKzPSufRewtsxUJMVg@mail.gmail.com>
Date:   Fri, 21 Jan 2022 15:21:49 +0800
From:   David Gow <davidgow@...gle.com>
To:     Daniel Latypov <dlatypov@...gle.com>
Cc:     Brendan Higgins <brendanhiggins@...gle.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        KUnit Development <kunit-dev@...glegroups.com>,
        "open list:KERNEL SELFTEST FRAMEWORK" 
        <linux-kselftest@...r.kernel.org>,
        Shuah Khan <skhan@...uxfoundation.org>
Subject: Re: [PATCH 3/5] kunit: reduce layering in string assertion macros

On Wed, Jan 19, 2022 at 6:35 AM Daniel Latypov <dlatypov@...gle.com> wrote:
>
> The current macro chain looks like:
> KUNIT_EXPECT_STREQ => KUNIT_EXPECT_STREQ_MSG => KUNIT_BINARY_STR_EQ_MSG_ASSERTION => KUNIT_BINARY_STR_ASSERTION.
> KUNIT_ASSERT_STREQ => KUNIT_ASSERT_STREQ_MSG => KUNIT_BINARY_STR_EQ_MSG_ASSERTION => KUNIT_BINARY_STR_ASSERTION.
> <ditto for STR_NE>
>
> After this change:
> KUNIT_EXPECT_STREQ => KUNIT_EXPECT_STREQ_MSG => KUNIT_BINARY_STR_ASSERTION.
> KUNIT_ASSERT_STREQ => KUNIT_ASSERT_STREQ_MSG => KUNIT_BINARY_STR_ASSERTION.
> <ditto for STR_NE>
>
> All the intermediate macro did was pass in "==" or "!=", so it seems
> better to just drop them at the cost of a bit more copy-paste.
>
> Signed-off-by: Daniel Latypov <dlatypov@...gle.com>
> ---

Agreed, I don't think the copy-paste here is significant enough to
have any real chance of causing problems. This is clearly an
improvement.

Reviewed-by: David Gow <davidgow@...gle.com>


-- David

>  include/kunit/test.h | 68 +++++++++++++-------------------------------
>  1 file changed, 20 insertions(+), 48 deletions(-)
>
> diff --git a/include/kunit/test.h b/include/kunit/test.h
> index c021945a75e3..d5dc1ef68bfe 100644
> --- a/include/kunit/test.h
> +++ b/include/kunit/test.h
> @@ -1098,30 +1098,6 @@ do {                                                                            \
>                         ##__VA_ARGS__);                                        \
>  } while (0)
>
> -#define KUNIT_BINARY_STR_EQ_MSG_ASSERTION(test,                                       \
> -                                         assert_type,                         \
> -                                         left,                                \
> -                                         right,                               \
> -                                         fmt,                                 \
> -                                         ...)                                 \
> -       KUNIT_BINARY_STR_ASSERTION(test,                                       \
> -                                  assert_type,                                \
> -                                  left, ==, right,                            \
> -                                  fmt,                                        \
> -                                  ##__VA_ARGS__)
> -
> -#define KUNIT_BINARY_STR_NE_MSG_ASSERTION(test,                                       \
> -                                         assert_type,                         \
> -                                         left,                                \
> -                                         right,                               \
> -                                         fmt,                                 \
> -                                         ...)                                 \
> -       KUNIT_BINARY_STR_ASSERTION(test,                                       \
> -                                  assert_type,                                \
> -                                  left, !=, right,                            \
> -                                  fmt,                                        \
> -                                  ##__VA_ARGS__)
> -
>  #define KUNIT_PTR_NOT_ERR_OR_NULL_MSG_ASSERTION(test,                         \
>                                                 assert_type,                   \
>                                                 ptr,                           \
> @@ -1371,12 +1347,11 @@ do {                                                                           \
>         KUNIT_EXPECT_STREQ_MSG(test, left, right, NULL)
>
>  #define KUNIT_EXPECT_STREQ_MSG(test, left, right, fmt, ...)                   \
> -       KUNIT_BINARY_STR_EQ_MSG_ASSERTION(test,                                \
> -                                         KUNIT_EXPECTATION,                   \
> -                                         left,                                \
> -                                         right,                               \
> -                                         fmt,                                 \
> -                                         ##__VA_ARGS__)
> +       KUNIT_BINARY_STR_ASSERTION(test,                                       \
> +                                  KUNIT_EXPECTATION,                          \
> +                                  left, ==, right,                            \
> +                                  fmt,                                        \
> +                                  ##__VA_ARGS__)
>
>  /**
>   * KUNIT_EXPECT_STRNEQ() - Expects that strings @left and @right are not equal.
> @@ -1393,12 +1368,11 @@ do {                                                                           \
>         KUNIT_EXPECT_STRNEQ_MSG(test, left, right, NULL)
>
>  #define KUNIT_EXPECT_STRNEQ_MSG(test, left, right, fmt, ...)                  \
> -       KUNIT_BINARY_STR_NE_MSG_ASSERTION(test,                                \
> -                                         KUNIT_EXPECTATION,                   \
> -                                         left,                                \
> -                                         right,                               \
> -                                         fmt,                                 \
> -                                         ##__VA_ARGS__)
> +       KUNIT_BINARY_STR_ASSERTION(test,                                       \
> +                                  KUNIT_EXPECTATION,                          \
> +                                  left, !=, right,                            \
> +                                  fmt,                                        \
> +                                  ##__VA_ARGS__)
>
>  /**
>   * KUNIT_EXPECT_NOT_ERR_OR_NULL() - Expects that @ptr is not null and not err.
> @@ -1648,12 +1622,11 @@ do {                                                                           \
>         KUNIT_ASSERT_STREQ_MSG(test, left, right, NULL)
>
>  #define KUNIT_ASSERT_STREQ_MSG(test, left, right, fmt, ...)                   \
> -       KUNIT_BINARY_STR_EQ_MSG_ASSERTION(test,                                \
> -                                         KUNIT_ASSERTION,                     \
> -                                         left,                                \
> -                                         right,                               \
> -                                         fmt,                                 \
> -                                         ##__VA_ARGS__)
> +       KUNIT_BINARY_STR_ASSERTION(test,                                       \
> +                                  KUNIT_ASSERTION,                            \
> +                                  left, ==, right,                            \
> +                                  fmt,                                        \
> +                                  ##__VA_ARGS__)
>
>  /**
>   * KUNIT_ASSERT_STRNEQ() - Expects that strings @left and @right are not equal.
> @@ -1670,12 +1643,11 @@ do {                                                                           \
>         KUNIT_ASSERT_STRNEQ_MSG(test, left, right, NULL)
>
>  #define KUNIT_ASSERT_STRNEQ_MSG(test, left, right, fmt, ...)                  \
> -       KUNIT_BINARY_STR_NE_MSG_ASSERTION(test,                                \
> -                                         KUNIT_ASSERTION,                     \
> -                                         left,                                \
> -                                         right,                               \
> -                                         fmt,                                 \
> -                                         ##__VA_ARGS__)
> +       KUNIT_BINARY_STR_ASSERTION(test,                                       \
> +                                  KUNIT_ASSERTION,                            \
> +                                  left, !=, right,                            \
> +                                  fmt,                                        \
> +                                  ##__VA_ARGS__)
>
>  /**
>   * KUNIT_ASSERT_NOT_ERR_OR_NULL() - Assertion that @ptr is not null and not err.
> --
> 2.34.1.703.g22d0c6ccf7-goog
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ