|test "expect condition" utility function |
|#define||expect(cond) (likely(cond) ? (void)0 : _expect_failure(__FILE__, __LINE__))|
|abort the program if condition is false More...|
|static NORETURN void||_expect_failure (const char *file, unsigned line)|
|Function to handle failed expectation. More...|
abort the program if condition is false
This is similar to assert(), but will not be excluded from a build even if NDEBUG is set. Use e.g., in test application to "assert" conditions, in order to prevent a different compilation mode (a release build?) from making the test non-functional.
The purpose of this macro is to help programmers find bugs in their programs.
A failed condition generates output similar to:
0x89abcdef *** RIOT kernel panic: FAILED CONDITION. ...
Where 0x89abcdef is an address. This address can be used with tools like
addr2line (or e.g.
arm-none-eabi-addr2line for ARM-based code),
gdb (with the command
info line *(0x89abcdef)) to identify the line the condition failed in.
Function to handle failed expectation.
|[in]||file||The file name of the file the expectation failed in|
|[in]||line||The code line of |