({ \
typeof(expr) _result = (expr); \
if (_result < 0) \
- log_test_failed("Expected \"%s\" to succeed, but got error: %s", #expr, STRERROR(_result)); \
+ log_test_failed("Expected \"%s\" to succeed, but got error: %"PRIiMAX"/%s", \
+ #expr, (intmax_t) _result, STRERROR(_result)); \
})
#endif
({ \
typeof(expr) _result = (expr); \
if (_result < 0) \
- log_test_failed("Expected \"%s\" to succeed, but got error: %s", #expr, STRERROR(_result)); \
+ log_test_failed("Expected \"%s\" to succeed, but got error: %"PRIiMAX"/%s", \
+ #expr, (intmax_t) _result, STRERROR(_result)); \
if (_result == 0) \
log_test_failed("Expected \"%s\" to be positive, but it is zero.", #expr); \
})
({ \
typeof(expr) _result = (expr); \
if (_result < 0) \
- log_test_failed("Expected \"%s\" to succeed, but got error: %s", #expr, STRERROR(_result)); \
+ log_test_failed("Expected \"%s\" to succeed, but got error: %"PRIiMAX"/%s", \
+ #expr, (intmax_t) _result, STRERROR(_result)); \
if (_result != 0) \
log_test_failed("Expected \"%s\" to be zero, but it is %"PRIiMAX".", \
#expr, (intmax_t) _result); \
typeof(expr1) _expr1 = (expr1); \
typeof(expr2) _expr2 = (expr2); \
if (_expr1 < 0) \
- log_test_failed("Expected \"%s\" to succeed, but got error: %s", #expr1, STRERROR(_expr1)); \
+ log_test_failed("Expected \"%s\" to succeed, but got error: %"PRIiMAX"/%s", \
+ #expr1, (intmax_t) _expr1, STRERROR(_expr1)); \
if (_expr1 != _expr2) \
log_test_failed("Expected \"%s == %s\", got %"PRIiMAX" != %"PRIiMAX, \
#expr1, #expr2, (intmax_t) _expr1, (intmax_t) _expr2); \
})
#endif
+/* For functions that return a boolean on success and set errno on failure. */
#ifdef __COVERITY__
# define ASSERT_OK_ERRNO(expr) __coverity_check__((expr) >= 0)
#else
({ \
typeof(expr) _result = (expr); \
if (_result < 0) \
- log_test_failed("Expected \"%s\" to succeed, but got error: %s", #expr, STRERROR(errno)); \
+ log_test_failed("Expected \"%s\" to succeed, but got errno: %d/%s", \
+ #expr, errno, STRERROR(errno)); \
})
#endif
({ \
typeof(expr) _result = (expr); \
if (_result < 0) \
- log_test_failed("Expected \"%s\" to succeed, but got error: %s", #expr, STRERROR(errno)); \
+ log_test_failed("Expected \"%s\" to succeed, but got errno: %d/%s", \
+ #expr, errno, STRERROR(errno)); \
if (_result != 0) \
log_test_failed("Expected \"%s\" to be zero, but it is %"PRIiMAX".", \
#expr, (intmax_t) _result); \
typeof(expr1) _expr1 = (expr1); \
typeof(expr2) _expr2 = (expr2); \
if (_expr1 < 0) \
- log_test_failed("Expected \"%s\" to succeed, but got error: %s", #expr1, STRERROR(errno)); \
+ log_test_failed("Expected \"%s\" to succeed, but got errno: %d/%s", \
+ #expr1, errno, STRERROR(errno)); \
if (_expr1 != _expr2) \
log_test_failed("Expected \"%s == %s\", but %"PRIiMAX" != %"PRIiMAX, \
#expr1, #expr2, (intmax_t) _expr1, (intmax_t) _expr2); \
int _expr1 = (expr1); \
int _expr2 = (expr2); \
if (_expr1 >= 0) \
- log_test_failed("Expected \"%s\" to fail with error \"%s\", but it succeeded", \
- #expr1, STRERROR(_expr2)); \
+ log_test_failed("Expected \"%s\" to fail with error %d/\"%s\", but it succeeded", \
+ #expr1, -_expr2, STRERROR(_expr2)); \
else if (-_expr1 != _expr2) \
- log_test_failed("Expected \"%s\" to fail with error \"%s\", but got the following error: %s", \
- #expr1, STRERROR(_expr2), STRERROR(_expr1)); \
+ log_test_failed("Expected \"%s\" to fail with error %d/\"%s\", but got the following error: %d/%s", \
+ #expr1, -_expr2, STRERROR(_expr2), _expr1, STRERROR(_expr1)); \
})
#endif
int _expr1 = (expr1); \
int _expr2 = (expr2); \
if (_expr1 >= 0) \
- log_test_failed("Expected \"%s\" to fail with error \"%s\", but it succeeded", \
- #expr1, STRERROR(_expr2)); \
+ log_test_failed("Expected \"%s\" to fail with errno %d/\"%s\", but it succeeded", \
+ #expr1, _expr2, STRERROR(_expr2)); \
else if (errno != _expr2) \
- log_test_failed("Expected \"%s\" to fail with error \"%s\", but got the following error: %s", \
- #expr1, STRERROR(_expr2), STRERROR(errno)); \
+ log_test_failed("Expected \"%s\" to fail with errno %d/\"%s\", but got the following errno: %d/%s", \
+ #expr1, _expr2, STRERROR(_expr2), errno, STRERROR(errno)); \
})
#endif