#include "fail.h"
#include "test.h"
#include "../str.h"
#include "../log.h"
#include "backtrace.h"
#include <stdarg.h>
void test_fail_va (const char *func, const char *file, int line, int skip, const char *fmt, va_list vargs)
{
// log it
log_output_tag(LOG_ERROR, "FAIL", func, fmt, vargs, " @@ %s@%s:%d - backtrace follows:", func, file, line);
// print out a stack dump, not including this function or the backtrace func
test_backtrace(skip + 2);
// then jump out
longjmp(_test_ctx.jmp_fail, TEST_FAIL);
}
void test_fail (const char *func, const char *file, int line, int skip, const char *fmt, ...)
{
va_list vargs;
va_start(vargs, fmt);
test_fail_va(func, file, line, skip, fmt, vargs);
va_end(vargs);
}
void test_test_fail (void)
{
fail_if(1, "testing failure: %s", "xxx");
}