subsys/testsuite: Add an assert for a zero return code

Many functions signal success by returning a return code of zero. Add
an assertion for this.

Some functions can return a positive value to indicate success, where
they want to convey some information. This is not handled by this
assert function.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2020-08-06 16:47:02 -06:00 committed by Anas Nashif
commit c5d85e175f

View file

@ -116,6 +116,14 @@ static inline void z_zassert(bool cond,
#define zassert_false(cond, msg, ...) zassert(!(cond), #cond " is true", \ #define zassert_false(cond, msg, ...) zassert(!(cond), #cond " is true", \
msg, ##__VA_ARGS__) msg, ##__VA_ARGS__)
/**
* @brief Assert that @a cond is 0 (success)
* @param cond Condition to check
* @param msg Optional message to print if the assertion fails
*/
#define zassert_ok(cond, msg, ...) zassert(!(cond), #cond " is non-zero", \
msg, ##__VA_ARGS__)
/** /**
* @brief Assert that @a ptr is NULL * @brief Assert that @a ptr is NULL
* @param ptr Pointer to compare * @param ptr Pointer to compare