summaryrefslogtreecommitdiffstats
path: root/include/kunit/test.h
diff options
context:
space:
mode:
authorEric Chan <ericchancf@google.com>2024-07-11 21:39:31 +0200
committerShuah Khan <skhan@linuxfoundation.org>2024-07-12 18:12:05 +0200
commit7d4087b013895524438f2522367c984f776e09e3 (patch)
treedcb80789de2e9f53e40953b5c4ea8120d610d4f7 /include/kunit/test.h
parentkunit: Fix the comment of KUNIT_ASSERT_STRNEQ as assertion (diff)
downloadlinux-7d4087b013895524438f2522367c984f776e09e3.tar.xz
linux-7d4087b013895524438f2522367c984f776e09e3.zip
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>
Diffstat (limited to 'include/kunit/test.h')
-rw-r--r--include/kunit/test.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/include/kunit/test.h b/include/kunit/test.h
index e37df1df5a92..fb58fa530c5e 100644
--- a/include/kunit/test.h
+++ b/include/kunit/test.h
@@ -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__)
/**