]> Git Repo - J-linux.git/commitdiff
kunit: Rename KUNIT_ASSERT_FAILURE to KUNIT_FAIL_AND_ABORT for readability
authorEric Chan <[email protected]>
Thu, 11 Jul 2024 19:39:31 +0000 (19:39 +0000)
committerShuah Khan <[email protected]>
Fri, 12 Jul 2024 16:12:05 +0000 (10:12 -0600)
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_FAIL_AND_ABORT. Makes the naming
consistent, with KUNIT_FAIL and KUNIT_FAIL_AND_ABORT being symmetrical.
Additionally, an explanation for KUNIT_FAIL_AND_ABORT has been added to
clarify its usage.

Signed-off-by: Eric Chan <[email protected]>
Reviewed-by: David Gow <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>
drivers/input/tests/input_test.c
include/kunit/assert.h
include/kunit/test.h

index 2fa5b725ae0a2a86cc8763e2d1d96b37c7f2a7af..9711ced180b8452421deae648953480a0d11d96d 100644 (file)
@@ -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_FAIL_AND_ABORT(test, "Register device failed: %d", ret);
        }
 
        test->priv = input_dev;
index 7e7490a74b13c195642eff5801e2e1f2971b10c0..bb879389f11d6ecf3e77f7e895b1b6b896e3ec8c 100644 (file)
@@ -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_FAIL_AND_ABORT that always fails.
  */
 struct kunit_fail_assert {
        struct kunit_assert assert;
index e37df1df5a92035fb469ae794c98b4106a07c49c..fb58fa530c5e2fbfaa251a5b0b0c5597b15293ef 100644 (file)
@@ -1228,7 +1228,18 @@ do {                                                                            \
                                                fmt,                           \
                                                ##__VA_ARGS__)
 
-#define KUNIT_ASSERT_FAILURE(test, fmt, ...) \
+/**
+ * KUNIT_FAIL_AND_ABORT() - Always causes a test to fail and abort 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 fail and abort when evaluated.
+ * See KUNIT_ASSERT_TRUE() for more information.
+ */
+#define KUNIT_FAIL_AND_ABORT(test, fmt, ...) \
        KUNIT_FAIL_ASSERTION(test, KUNIT_ASSERTION, fmt, ##__VA_ARGS__)
 
 /**
This page took 0.057013 seconds and 4 git commands to generate.