summaryrefslogtreecommitdiff
path: root/include/kunit/test.h
diff options
context:
space:
mode:
authorDaniel Latypov <dlatypov@google.com>2022-01-25 13:00:10 -0800
committerShuah Khan <skhan@linuxfoundation.org>2022-01-31 11:55:33 -0700
commit064ff292aca500d6b911dca6abe1ece22620d475 (patch)
treed3c74374831a54fda8c9568ac3a2a784733ebbef /include/kunit/test.h
parent6419abb80e82c603bbec6d7f5af6c2f79fa5c4ae (diff)
kunit: consolidate KUNIT_INIT_BINARY_ASSERT_STRUCT macros
We currently have 2 other versions of KUNIT_INIT_BINARY_ASSERT_STRUCT. The only differences are that * the format funcition they pass is different * the types of left_val/right_val should be different (integral, pointer, string). The latter doesn't actually matter since these macros are just plumbing them along to KUNIT_ASSERTION where they will get type checked. So combine them all into a single KUNIT_INIT_BINARY_ASSERT_STRUCT that now also takes the format function as a parameter. Signed-off-by: Daniel Latypov <dlatypov@google.com> Reviewed-by: David Gow <davidgow@google.com> Reviewed-by: Brendan Higgins <brendanhiggins@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'include/kunit/test.h')
-rw-r--r--include/kunit/test.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/include/kunit/test.h b/include/kunit/test.h
index bf82c313223b..a93dfb8ff393 100644
--- a/include/kunit/test.h
+++ b/include/kunit/test.h
@@ -864,7 +864,7 @@ void kunit_do_failed_assertion(struct kunit *test,
*/
#define KUNIT_BASE_BINARY_ASSERTION(test, \
assert_class, \
- ASSERT_CLASS_INIT, \
+ format_func, \
assert_type, \
left, \
op, \
@@ -879,11 +879,12 @@ do { \
assert_type, \
__left op __right, \
assert_class, \
- ASSERT_CLASS_INIT(#op, \
- #left, \
- __left, \
- #right, \
- __right), \
+ KUNIT_INIT_BINARY_ASSERT_STRUCT(format_func, \
+ #op, \
+ #left, \
+ __left, \
+ #right, \
+ __right), \
fmt, \
##__VA_ARGS__); \
} while (0)
@@ -897,7 +898,7 @@ do { \
...) \
KUNIT_BASE_BINARY_ASSERTION(test, \
kunit_binary_assert, \
- KUNIT_INIT_BINARY_ASSERT_STRUCT, \
+ kunit_binary_assert_format, \
assert_type, \
left, op, right, \
fmt, \
@@ -912,7 +913,7 @@ do { \
...) \
KUNIT_BASE_BINARY_ASSERTION(test, \
kunit_binary_ptr_assert, \
- KUNIT_INIT_BINARY_PTR_ASSERT_STRUCT, \
+ kunit_binary_ptr_assert_format, \
assert_type, \
left, op, right, \
fmt, \
@@ -933,7 +934,8 @@ do { \
assert_type, \
strcmp(__left, __right) op 0, \
kunit_binary_str_assert, \
- KUNIT_INIT_BINARY_STR_ASSERT_STRUCT(#op, \
+ KUNIT_INIT_BINARY_ASSERT_STRUCT(kunit_binary_str_assert_format,\
+ #op, \
#left, \
__left, \
#right, \