ztest: Add docstring for zassume macro

Add a detailed docstring to the zassume() macro that describes what it does
and how its usage is different from zassert.

Signed-off-by: Aaron Massey <aaronmassey@google.com>
This commit is contained in:
Aaron Massey 2022-08-03 17:38:45 -06:00 committed by Carles Cufí
commit 2bc23e0543

View file

@ -141,6 +141,24 @@ static inline bool z_zassume(bool cond, const char *default_msg, const char *fil
} \
} while (0)
/**
* @brief Skip the test, if @a cond is false
*
* You probably don't need to call this macro directly. You should
* instead use zassume_{condition} macros below.
*
* Note that when CONFIG_MULTITHREADING=n macro returns from the function. It's then expected that
* in that case ztest assumes will be used only in the context of the test function.
*
* NOTE: zassume should not be used to replace zassert, the goal of zassume is to skip tests that
* would otherwise fail due to a zassert on some other dependent behavior that is *not* under test,
* thus reducing what could be tens to hundreds of assertion failures to investigate down to a few
* failures only.
*
* @param cond Condition to check
* @param msg Optional, can be NULL. Message to print if @a cond is false.
* @param default_msg Message to print if @a cond is false
*/
#define zassume(cond, default_msg, msg, ...) \
do { \
bool _ret = z_zassume(cond, msg ? ("(" default_msg ")") : (default_msg), __FILE__, \