diff options
Diffstat (limited to 'tests/unit_tests/openvpn/mock_msg.c')
-rw-r--r-- | tests/unit_tests/openvpn/mock_msg.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/unit_tests/openvpn/mock_msg.c b/tests/unit_tests/openvpn/mock_msg.c index d74efaa..a291f8f 100644 --- a/tests/unit_tests/openvpn/mock_msg.c +++ b/tests/unit_tests/openvpn/mock_msg.c @@ -31,8 +31,9 @@ #include <stdlib.h> #include <setjmp.h> #include <stdint.h> +#ifndef NO_CMOCKA #include <cmocka.h> - +#endif #include "errlevel.h" #include "error.h" @@ -74,6 +75,8 @@ x_msg(const unsigned int flags, const char *format, ...) va_end(arglist); } +/* Allow to use mock_msg.c outside of UT */ +#ifndef NO_CMOCKA void assert_failed(const char *filename, int line, const char *condition) { @@ -81,6 +84,15 @@ assert_failed(const char *filename, int line, const char *condition) /* Keep compiler happy. Should not happen, mock_assert() does not return */ exit(1); } +#else /* ifndef NO_CMOCKA */ +void +assert_failed(const char *filename, int line, const char *condition) +{ + msg(M_FATAL, "Assertion failed at %s:%d (%s)", filename, line, condition ? condition : ""); + _exit(1); +} +#endif + /* * Fail memory allocation. Don't use msg() because it tries |