diff options
author | Jacques Lucke <jacques@blender.org> | 2020-08-26 23:02:02 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-08-26 23:02:02 +0300 |
commit | 8a9912eaf81bab73a12621a4c0987c37a865fe50 (patch) | |
tree | 0e51335adf6fdf6ccfa5b0f240ebc72913d18513 /intern/clog | |
parent | d8cf6ee3163b15d70ba9068fa198d433ce6f3d8f (diff) |
Tests: fail automated tests on memory leaks and other internal errors
This adds a new `--debug-exit-on-error` flag. When it is set, Blender
will abort with a non-zero exit code when there are internal errors.
Currently, "internal errors" includes memory leaks detected by
guardedalloc and error/fatal log entries in clog.
The new flag is passed to Blender in various places where automated
tests are run. Furthermore, the `--debug-memory` flag is used in tests,
because that makes the verbose output more useful, when dealing
with memory leaks.
Reviewers: brecht, sergey
Differential Revision: https://developer.blender.org/D8665
Diffstat (limited to 'intern/clog')
-rw-r--r-- | intern/clog/CLG_log.h | 1 | ||||
-rw-r--r-- | intern/clog/clog.c | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/intern/clog/CLG_log.h b/intern/clog/CLG_log.h index 35515a1d5c6..a2841c5c8b3 100644 --- a/intern/clog/CLG_log.h +++ b/intern/clog/CLG_log.h @@ -139,6 +139,7 @@ void CLG_exit(void); void CLG_output_set(void *file_handle); void CLG_output_use_basename_set(int value); void CLG_output_use_timestamp_set(int value); +void CLG_error_fn_set(void (*error_fn)(void *file_handle)); void CLG_fatal_fn_set(void (*fatal_fn)(void *file_handle)); void CLG_backtrace_fn_set(void (*fatal_fn)(void *file_handle)); diff --git a/intern/clog/clog.c b/intern/clog/clog.c index d384b9a89e6..84b850f5042 100644 --- a/intern/clog/clog.c +++ b/intern/clog/clog.c @@ -98,6 +98,7 @@ typedef struct CLogContext { } default_type; struct { + void (*error_fn)(void *file_handle); void (*fatal_fn)(void *file_handle); void (*backtrace_fn)(void *file_handle); } callbacks; @@ -352,6 +353,13 @@ static CLG_LogType *clg_ctx_type_register(CLogContext *ctx, const char *identifi return ty; } +static void clg_ctx_error_action(CLogContext *ctx) +{ + if (ctx->callbacks.error_fn != NULL) { + ctx->callbacks.error_fn(ctx->output_file); + } +} + static void clg_ctx_fatal_action(CLogContext *ctx) { if (ctx->callbacks.fatal_fn != NULL) { @@ -522,6 +530,10 @@ void CLG_logf(CLG_LogType *lg, clg_ctx_backtrace(lg->ctx); } + if (severity == CLG_SEVERITY_ERROR) { + clg_ctx_error_action(lg->ctx); + } + if (severity == CLG_SEVERITY_FATAL) { clg_ctx_fatal_action(lg->ctx); } @@ -555,6 +567,12 @@ static void CLG_ctx_output_use_timestamp_set(CLogContext *ctx, int value) } } +/** Action on error severity. */ +static void CLT_ctx_error_fn_set(CLogContext *ctx, void (*error_fn)(void *file_handle)) +{ + ctx->callbacks.error_fn = error_fn; +} + /** Action on fatal severity. */ static void CLG_ctx_fatal_fn_set(CLogContext *ctx, void (*fatal_fn)(void *file_handle)) { @@ -674,6 +692,11 @@ void CLG_output_use_timestamp_set(int value) CLG_ctx_output_use_timestamp_set(g_ctx, value); } +void CLG_error_fn_set(void (*error_fn)(void *file_handle)) +{ + CLT_ctx_error_fn_set(g_ctx, error_fn); +} + void CLG_fatal_fn_set(void (*fatal_fn)(void *file_handle)) { CLG_ctx_fatal_fn_set(g_ctx, fatal_fn); |