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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABVgOSkJOyLDZmPk5vj+o7aRbEZFDJvynWRacNJZ_M_gn9x1XQ@mail.gmail.com>
Date: Thu, 11 Jul 2024 11:49:33 +0800
From: David Gow <davidgow@...gle.com>
To: Eric Chan <ericchancf@...gle.com>
Cc: brendan.higgins@...ux.dev, rmoar@...gle.com, 
	linux-kselftest@...r.kernel.org, kunit-dev@...glegroups.com, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/3] kunit: Rename KUNIT_ASSERT_FAILURE to KUNIT_ASSERT
 for readability

On Thu, 11 Jul 2024 at 01:06, Eric Chan <ericchancf@...gle.com> wrote:
>
> Both KUNIT_FAIL and KUNIT_ASSERT_FAILURE defined to KUNIT_FAIL_ASSERTION
> with different tpye of kunit_assert_type. The current naming of
> KUNIT_ASSERT_FAILURE and KUNIT_FAIL_ASSERTION is confusing due to their
> similarities. To improve readability and symmetry, renames
> KUNIT_ASSERT_FAILURE to KUNIT_ASSERT. Makes the naming consistent,
> with KUNIT_FAIL and KUNIT_ASSERT being symmetrical.
> Additionally, an explanation for KUNIT_ASSERT has been added to clarify
> its usage.
>
> Signed-off-by: Eric Chan <ericchancf@...gle.com>
> ---

I personally am not a fan of KUNIT_ASSERT() as a name here: to me it
implies that we're checking a boolean (like KUNIT_ASSERT_TRUE()).

Does making this 'KUNIT_FAIL_AND_EXIT()' / 'KUNIT_FAIL_AND_ABORT()' or
similar seem clearer to you?

(Or possibly we could make this KUNIT_FAIL(), and make the existing
KUNIT_FAIL() become KUNIT_MARK_FAILED(), though I think it's not worth
the churn personally.)

-- David




>  drivers/input/tests/input_test.c |  2 +-
>  include/kunit/assert.h           |  2 +-
>  include/kunit/test.h             | 13 ++++++++++++-
>  3 files changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/input/tests/input_test.c b/drivers/input/tests/input_test.c
> index 2fa5b725ae0a..cbab24a265fa 100644
> --- a/drivers/input/tests/input_test.c
> +++ b/drivers/input/tests/input_test.c
> @@ -31,7 +31,7 @@ static int input_test_init(struct kunit *test)
>         ret = input_register_device(input_dev);
>         if (ret) {
>                 input_free_device(input_dev);
> -               KUNIT_ASSERT_FAILURE(test, "Register device failed: %d", ret);
> +               KUNIT_ASSERT(test, "Register device failed: %d", ret);
>         }
>
>         test->priv = input_dev;
> diff --git a/include/kunit/assert.h b/include/kunit/assert.h
> index 24c2b9fa61e8..02c6f7bb1d26 100644
> --- a/include/kunit/assert.h
> +++ b/include/kunit/assert.h
> @@ -60,7 +60,7 @@ void kunit_assert_prologue(const struct kunit_loc *loc,
>   * struct kunit_fail_assert - Represents a plain fail expectation/assertion.
>   * @assert: The parent of this type.
>   *
> - * Represents a simple KUNIT_FAIL/KUNIT_ASSERT_FAILURE that always fails.
> + * Represents a simple KUNIT_FAIL/KUNIT_ASSERT that always fails.
>   */
>  struct kunit_fail_assert {
>         struct kunit_assert assert;
> diff --git a/include/kunit/test.h b/include/kunit/test.h
> index 87a232421089..d1b085fd5dc3 100644
> --- a/include/kunit/test.h
> +++ b/include/kunit/test.h
> @@ -1193,7 +1193,18 @@ do {                                                                            \
>                                                 fmt,                           \
>                                                 ##__VA_ARGS__)
>
> -#define KUNIT_ASSERT_FAILURE(test, fmt, ...) \
> +/**
> + * KUNIT_ASSERT() - Always causes a test to assert when evaluated.
> + * @test: The test context object.
> + * @fmt: an informational message to be printed when the assertion is made.
> + * @...: string format arguments.
> + *
> + * The opposite of KUNIT_SUCCEED(), it is an assertion that always fails. In
> + * other words, it always results in a failed assertion, and consequently
> + * always causes the test case to assert when evaluated. See KUNIT_ASSERT_TRUE()
> + * for more information.
> + */
> +#define KUNIT_ASSERT(test, fmt, ...) \
>         KUNIT_FAIL_ASSERTION(test, KUNIT_ASSERTION, fmt, ##__VA_ARGS__)
>
>  /**
> --
> 2.45.2.803.g4e1b14247a-goog
>

Download attachment "smime.p7s" of type "application/pkcs7-signature" (4014 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ