mirror of
https://github.com/espressif/openthread.git
synced 2026-08-04 09:57:47 +00:00
[unit-test] update test_util SuccessOrQuit/VerifyOrQuit macros (#4367)
This commit is contained in:
committed by
Jonathan Hui
parent
554407d107
commit
720e9130da
+32
-16
@@ -39,24 +39,40 @@ extern "C" {
|
||||
// Enable main functions
|
||||
#define ENABLE_TEST_MAIN
|
||||
|
||||
#define SuccessOrQuit(ERR, MSG) \
|
||||
do \
|
||||
{ \
|
||||
if ((ERR) != OT_ERROR_NONE) \
|
||||
{ \
|
||||
fprintf(stderr, "\nFAILED %s:%d - %s\n", __FUNCTION__, __LINE__, MSG); \
|
||||
exit(-1); \
|
||||
} \
|
||||
/**
|
||||
* This macro verifies a given error status to be successful (compared against value zero (0)), otherwise, it emits a
|
||||
* given error messages and exits the program.
|
||||
*
|
||||
* @param[in] aStatus A scalar error status to be evaluated against zero (0).
|
||||
* @param[in] aMessage A message (text string) to print on failure.
|
||||
*
|
||||
*/
|
||||
#define SuccessOrQuit(aStatus, aMessage) \
|
||||
do \
|
||||
{ \
|
||||
if ((aStatus) != 0) \
|
||||
{ \
|
||||
fprintf(stderr, "\nFAILED %s:%d - %s\n", __FUNCTION__, __LINE__, aMessage); \
|
||||
exit(-1); \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#define VerifyOrQuit(TST, MSG) \
|
||||
do \
|
||||
{ \
|
||||
if (!(TST)) \
|
||||
{ \
|
||||
fprintf(stderr, "\nFAILED %s:%d - %s\n", __FUNCTION__, __LINE__, MSG); \
|
||||
exit(-1); \
|
||||
} \
|
||||
/**
|
||||
* This macro verifies that a given boolean condition is true, otherwise, it emits a given error message and exits the
|
||||
* program.
|
||||
*
|
||||
* @param[in] aCondition A Boolean expression to be evaluated.
|
||||
* @param[in] aMessage A message (text string) to print on failure.
|
||||
*
|
||||
*/
|
||||
#define VerifyOrQuit(aCondition, aMessage) \
|
||||
do \
|
||||
{ \
|
||||
if (!(aCondition)) \
|
||||
{ \
|
||||
fprintf(stderr, "\nFAILED %s:%d - %s\n", __FUNCTION__, __LINE__, aMessage); \
|
||||
exit(-1); \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
//#define CompileTimeAssert(COND, MSG) typedef char __C_ASSERT__[(COND)?1:-1]
|
||||
|
||||
Reference in New Issue
Block a user