aboutsummaryrefslogtreecommitdiff
path: root/include/test
diff options
context:
space:
mode:
authorRamon Fried <ramon.fried@gmail.com>2018-06-21 17:47:16 +0300
committerTom Rini <trini@konsulko.com>2018-07-19 16:17:58 -0400
commit8d545790729434f4ba718dd9a6a1b55dcf7e94c4 (patch)
tree0dde4cf1390898128070d12ee5d01515809f0f07 /include/test
parentf7e48c54b246c460503e90315d0cd50ccbd586c6 (diff)
downloadu-boot-8d545790729434f4ba718dd9a6a1b55dcf7e94c4.zip
u-boot-8d545790729434f4ba718dd9a6a1b55dcf7e94c4.tar.gz
u-boot-8d545790729434f4ba718dd9a6a1b55dcf7e94c4.tar.bz2
test: Add ut_assertnull macro
Add ut_assertnull macro to include/test/ut.h For testing of functions that returns NULL on errors. Signed-off-by: Ramon Fried <ramon.fried@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/test')
-rw-r--r--include/test/ut.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/test/ut.h b/include/test/ut.h
index 59b23a2..fce75fd 100644
--- 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); \