1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

checkasm: Make checkasm_fail_func return whether we should print verbosely

This makes it easier to implement custom error printouts in tests.

This is a port of dav1d's commit
13a7d78655f8747c2cd01e8a48d44dcc7f60a8e5 into ffmpeg's checkasm.

Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
Martin Storsjö
2025-03-22 00:47:01 +02:00
parent 4db571e516
commit 37c664a253
2 changed files with 6 additions and 5 deletions

View File

@ -1081,8 +1081,9 @@ int checkasm_bench_func(void)
!wildstrcmp(state.current_func->name, state.bench_pattern); !wildstrcmp(state.current_func->name, state.bench_pattern);
} }
/* Indicate that the current test has failed */ /* Indicate that the current test has failed, return whether verbose printing
void checkasm_fail_func(const char *msg, ...) * is requested. */
int checkasm_fail_func(const char *msg, ...)
{ {
if (state.current_func_ver && state.current_func_ver->cpu && if (state.current_func_ver && state.current_func_ver->cpu &&
state.current_func_ver->ok) state.current_func_ver->ok)
@ -1099,6 +1100,7 @@ void checkasm_fail_func(const char *msg, ...)
state.current_func_ver->ok = 0; state.current_func_ver->ok = 0;
state.num_failed++; state.num_failed++;
} }
return state.verbose;
} }
void checkasm_set_signal_handler_state(int enabled) { void checkasm_set_signal_handler_state(int enabled) {
@ -1180,8 +1182,7 @@ int checkasm_check_##type(const char *file, int line, \
break; \ break; \
if (y == h) \ if (y == h) \
return 0; \ return 0; \
checkasm_fail_func("%s:%d", file, line); \ if (!checkasm_fail_func("%s:%d", file, line)) \
if (!state.verbose) \
return 1; \ return 1; \
fprintf(stderr, "%s:\n", name); \ fprintf(stderr, "%s:\n", name); \
while (h--) { \ while (h--) { \

View File

@ -152,7 +152,7 @@ struct CheckasmPerf;
void *checkasm_check_func(void *func, const char *name, ...) av_printf_format(2, 3); void *checkasm_check_func(void *func, const char *name, ...) av_printf_format(2, 3);
int checkasm_bench_func(void); int checkasm_bench_func(void);
void checkasm_fail_func(const char *msg, ...) av_printf_format(1, 2); int checkasm_fail_func(const char *msg, ...) av_printf_format(1, 2);
struct CheckasmPerf *checkasm_get_perf_context(void); struct CheckasmPerf *checkasm_get_perf_context(void);
void checkasm_report(const char *name, ...) av_printf_format(1, 2); void checkasm_report(const char *name, ...) av_printf_format(1, 2);
void checkasm_set_signal_handler_state(int enabled); void checkasm_set_signal_handler_state(int enabled);