Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kunit: Rename KUNIT_ASSERT_FAILURE to KUNIT_FAIL_AND_ABORT for readability

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 <ericchancf@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Eric Chan and committed by
Shuah Khan
7d4087b0 2be32bbe

+14 -3
+1 -1
drivers/input/tests/input_test.c
··· 31 31 ret = input_register_device(input_dev); 32 32 if (ret) { 33 33 input_free_device(input_dev); 34 - KUNIT_ASSERT_FAILURE(test, "Register device failed: %d", ret); 34 + KUNIT_FAIL_AND_ABORT(test, "Register device failed: %d", ret); 35 35 } 36 36 37 37 test->priv = input_dev;
+1 -1
include/kunit/assert.h
··· 60 60 * struct kunit_fail_assert - Represents a plain fail expectation/assertion. 61 61 * @assert: The parent of this type. 62 62 * 63 - * Represents a simple KUNIT_FAIL/KUNIT_ASSERT_FAILURE that always fails. 63 + * Represents a simple KUNIT_FAIL/KUNIT_FAIL_AND_ABORT that always fails. 64 64 */ 65 65 struct kunit_fail_assert { 66 66 struct kunit_assert assert;
+12 -1
include/kunit/test.h
··· 1228 1228 fmt, \ 1229 1229 ##__VA_ARGS__) 1230 1230 1231 - #define KUNIT_ASSERT_FAILURE(test, fmt, ...) \ 1231 + /** 1232 + * KUNIT_FAIL_AND_ABORT() - Always causes a test to fail and abort when evaluated. 1233 + * @test: The test context object. 1234 + * @fmt: an informational message to be printed when the assertion is made. 1235 + * @...: string format arguments. 1236 + * 1237 + * The opposite of KUNIT_SUCCEED(), it is an assertion that always fails. In 1238 + * other words, it always results in a failed assertion, and consequently 1239 + * always causes the test case to fail and abort when evaluated. 1240 + * See KUNIT_ASSERT_TRUE() for more information. 1241 + */ 1242 + #define KUNIT_FAIL_AND_ABORT(test, fmt, ...) \ 1232 1243 KUNIT_FAIL_ASSERTION(test, KUNIT_ASSERTION, fmt, ##__VA_ARGS__) 1233 1244 1234 1245 /**