projects
/
project
/
bcm63xx
/
u-boot.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
f7e48c5
)
test: Add ut_assertnull macro
author
Ramon Fried
<
[email protected]
>
Thu, 21 Jun 2018 14:47:16 +0000
(17:47 +0300)
committer
Tom Rini
<
[email protected]
>
Thu, 19 Jul 2018 20:17:58 +0000
(16:17 -0400)
Add ut_assertnull macro to include/test/ut.h
For testing of functions that returns NULL on errors.
Signed-off-by: Ramon Fried <
[email protected]
>
Reviewed-by: Simon Glass <
[email protected]
>
include/test/ut.h
patch
|
blob
|
history
diff --git
a/include/test/ut.h
b/include/test/ut.h
index 59b23a25a4de35d3c173d461bd7c7719b83b4f6f..fce75fd12a0d970b199b4fd8186e09211aa7ed40 100644
(file)
--- a/
include/test/ut.h
+++ b/
include/test/ut.h
@@
-90,6
+90,18
@@
void ut_failf(struct unit_test_state *uts, const char *fname, int line,
} \
}
+/* Assert that a pointer is NULL */
+#define ut_assertnull(expr) { \
+ const void *val = (expr); \
+ \
+ if (val != NULL) { \
+ ut_failf(uts, __FILE__, __LINE__, __func__, \
+ #expr " != NULL", \
+ "Expected NULL, got %p", val); \
+ return CMD_RET_FAILURE; \
+ } \
+}
+
/* Assert that a pointer is not NULL */
#define ut_assertnonnull(expr) { \
const void *val = (expr); \