test: Add ut_assertnull macro
PATCH 1/1 test: Add ut_assertnull macro
Add ut_assertnull macro to include/test/ut.h For testing of functions that returns NULL on errors.
--- include/test/ut.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
include/test/ut.h +12 -0
@@ -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); \
Signature · 1 line
2.17.1
PATCH 1/1 test: Add ut_assertnull macro
Hi Simon.
Would love to get this reviewed. can you assist ?
Thanks.
Ramon.
Quoted 35 lines · Ramon Fried
Add
ut_assertnullmacro toinclude/test/ut.hFor testing of functions that returns NULL on errors.Signed-off-by Ramon Fried <[email protected]>--- include/test/ut.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)include/test/ut.h +12
-1@@ -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); \ --2.17.1
PATCH 1/1 test: Add ut_assertnull macro
In reply to Ramon FriedQuoted 8 lines · Ramon Fried
Add
ut_assertnullmacro toinclude/test/ut.hFor testing of functions that returns NULL on errors.Signed-off-by Ramon Fried <[email protected]>--- include/test/ut.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
PATCH 1/1 test: Add ut_assertnull macro
Quoted 11 lines · Simon Glass
Quoted 8 lines · Ramon Fried
Add
ut_assertnullmacro toinclude/test/ut.hFor testing of functions that returns NULL on errors.Signed-off-by Ramon Fried <[email protected]>--- include/test/ut.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)Reviewed-by Simon Glass <[email protected]>
Thanks!
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Quoted 5 lines · Ramon Fried
Add
ut_assertnullmacro toinclude/test/ut.hFor testing of functions that returns NULL on errors.Signed-off-by Ramon Fried <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180720/9e5ed9fb/attachment.sig>