Files
swupd-client/test/unit/test_helper.h
Otavio Pontes db512848c7 signature: Add a unit test for signature
Create a unit test for signature checking.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-18 10:20:41 -07:00

30 lines
663 B
C

#include <stdlib.h>
#define print_error(_msg) printf("Test error(%s:%d): %s\n", __FILE__, __LINE__, _msg);
/*
* Assert and print error message if _exp is false.
*/
#define check_msg(_exp, _msg) \
do { \
if (!(_exp)) { \
print_error(_msg); \
exit(EXIT_FAILURE); \
} \
} while(0)
/*
* Assert and print error message if _exp is false.
* Goto to label instead of exiting.
*/
#define check_msg_goto(_exp, _msg, _label) \
do { \
if (!(_exp)) { \
print_error(_msg); \
goto _label; \
} \
} while(0)
#define check(_exp) check_msg(_exp, "failed")
#define check_goto(_exp, _label) check_msg_goto(_exp, "failed", _label)