mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-13 10:56:15 +00:00
lib: use critical log level for assertion failure messages
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
This commit is contained in:
parent
df11a0f4a8
commit
0167619bbc
@ -897,27 +897,24 @@ static bool run_under_gdb(void)
|
|||||||
strncmp(basename(buf), "gdb", 3) == 0);
|
strncmp(basename(buf), "gdb", 3) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __igt_fail_assert(int exitcode, const char *file,
|
void __igt_fail_assert(int exitcode, const char *domain, const char *file,
|
||||||
const int line, const char *func, const char *assertion,
|
const int line, const char *func, const char *assertion,
|
||||||
const char *f, ...)
|
const char *f, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
int err = errno;
|
int err = errno;
|
||||||
char *err_str = NULL;
|
|
||||||
|
|
||||||
|
igt_log(domain, IGT_LOG_CRITICAL,
|
||||||
|
"Test assertion failure function %s, file %s:%i:\n", func, file,
|
||||||
|
line);
|
||||||
|
igt_log(domain, IGT_LOG_CRITICAL, "Failed assertion: %s\n", assertion);
|
||||||
if (err)
|
if (err)
|
||||||
asprintf(&err_str, "Last errno: %i, %s\n", err, strerror(err));
|
igt_log(domain, IGT_LOG_CRITICAL, "Last errno: %i, %s\n", err,
|
||||||
|
strerror(err));
|
||||||
printf("Test assertion failure function %s, file %s:%i:\n"
|
|
||||||
"Failed assertion: %s\n"
|
|
||||||
"%s",
|
|
||||||
func, file, line, assertion, err_str ?: "");
|
|
||||||
|
|
||||||
free(err_str);
|
|
||||||
|
|
||||||
if (f) {
|
if (f) {
|
||||||
va_start(args, f);
|
va_start(args, f);
|
||||||
vprintf(f, args);
|
igt_vlog(domain, IGT_LOG_CRITICAL, f, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,11 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
|
#ifndef IGT_LOG_DOMAIN
|
||||||
|
#define IGT_LOG_DOMAIN (NULL)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
extern const char* __igt_test_description __attribute__((weak));
|
extern const char* __igt_test_description __attribute__((weak));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -215,8 +220,8 @@ void __igt_skip_check(const char *file, const int line,
|
|||||||
void igt_success(void);
|
void igt_success(void);
|
||||||
|
|
||||||
void igt_fail(int exitcode) __attribute__((noreturn));
|
void igt_fail(int exitcode) __attribute__((noreturn));
|
||||||
__attribute__((format(printf, 6, 7)))
|
__attribute__((format(printf, 7, 8)))
|
||||||
void __igt_fail_assert(int exitcode, const char *file,
|
void __igt_fail_assert(int exitcode, const char *domain, const char *file,
|
||||||
const int line, const char *func, const char *assertion,
|
const int line, const char *func, const char *assertion,
|
||||||
const char *format, ...)
|
const char *format, ...)
|
||||||
__attribute__((noreturn));
|
__attribute__((noreturn));
|
||||||
@ -232,7 +237,7 @@ void igt_exit(void) __attribute__((noreturn));
|
|||||||
*/
|
*/
|
||||||
#define igt_assert(expr) \
|
#define igt_assert(expr) \
|
||||||
do { if (!(expr)) \
|
do { if (!(expr)) \
|
||||||
__igt_fail_assert(99, __FILE__, __LINE__, __func__, #expr , NULL); \
|
__igt_fail_assert(99, IGT_LOG_DOMAIN, __FILE__, __LINE__, __func__, #expr , NULL); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -249,7 +254,7 @@ void igt_exit(void) __attribute__((noreturn));
|
|||||||
*/
|
*/
|
||||||
#define igt_assert_f(expr, f...) \
|
#define igt_assert_f(expr, f...) \
|
||||||
do { if (!(expr)) \
|
do { if (!(expr)) \
|
||||||
__igt_fail_assert(99, __FILE__, __LINE__, __func__, #expr , f); \
|
__igt_fail_assert(99, IGT_LOG_DOMAIN, __FILE__, __LINE__, __func__, #expr , f); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -294,7 +299,7 @@ void igt_exit(void) __attribute__((noreturn));
|
|||||||
do { \
|
do { \
|
||||||
int __n1 = (n1), __n2 = (n2); \
|
int __n1 = (n1), __n2 = (n2); \
|
||||||
if (__n1 cmp __n2) ; else \
|
if (__n1 cmp __n2) ; else \
|
||||||
__igt_fail_assert(99, __FILE__, __LINE__, __func__, \
|
__igt_fail_assert(99, IGT_LOG_DOMAIN, __FILE__, __LINE__, __func__, \
|
||||||
#n1 " " #cmp " " #n2, \
|
#n1 " " #cmp " " #n2, \
|
||||||
"error: %d " #ncmp " %d\n", __n1, __n2); \
|
"error: %d " #ncmp " %d\n", __n1, __n2); \
|
||||||
} while (0)
|
} while (0)
|
||||||
@ -303,7 +308,7 @@ void igt_exit(void) __attribute__((noreturn));
|
|||||||
do { \
|
do { \
|
||||||
uint32_t __n1 = (n1), __n2 = (n2); \
|
uint32_t __n1 = (n1), __n2 = (n2); \
|
||||||
if (__n1 cmp __n2) ; else \
|
if (__n1 cmp __n2) ; else \
|
||||||
__igt_fail_assert(99, __FILE__, __LINE__, __func__, \
|
__igt_fail_assert(99, IGT_LOG_DOMAIN, __FILE__, __LINE__, __func__, \
|
||||||
#n1 " " #cmp " " #n2, \
|
#n1 " " #cmp " " #n2, \
|
||||||
"error: %#x " #ncmp " %#x\n", __n1, __n2); \
|
"error: %#x " #ncmp " %#x\n", __n1, __n2); \
|
||||||
} while (0)
|
} while (0)
|
||||||
@ -512,10 +517,6 @@ bool igt_run_in_simulation(void);
|
|||||||
void igt_skip_on_simulation(void);
|
void igt_skip_on_simulation(void);
|
||||||
|
|
||||||
/* structured logging */
|
/* structured logging */
|
||||||
#ifndef IGT_LOG_DOMAIN
|
|
||||||
#define IGT_LOG_DOMAIN (NULL)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum igt_log_level {
|
enum igt_log_level {
|
||||||
IGT_LOG_DEBUG,
|
IGT_LOG_DEBUG,
|
||||||
IGT_LOG_INFO,
|
IGT_LOG_INFO,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user