diff mbox series

[FFmpeg-devel,1/2] checkasm: add helper to report a fatal signal

Message ID 20231116160504.37435-1-remi@remlab.net
State Accepted
Commit 286d6742218ba0235c32876b50bf593cb1986353
Headers show
Series [FFmpeg-devel,1/2] checkasm: add helper to report a fatal signal | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Rémi Denis-Courmont Nov. 16, 2023, 4:05 p.m. UTC
---
 tests/checkasm/checkasm.c | 15 +++++++++++----
 tests/checkasm/checkasm.h |  1 +
 2 files changed, 12 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 708119e7c6..c67cf58922 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -23,10 +23,8 @@ 
 #include "config.h"
 #include "config_components.h"
 
-#if CONFIG_LINUX_PERF
-# ifndef _GNU_SOURCE
-#  define _GNU_SOURCE // for syscall (performance monitoring API)
-# endif
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE // for syscall (performance monitoring API), strsignal()
 #endif
 
 #include <stdarg.h>
@@ -863,6 +861,15 @@  void checkasm_fail_func(const char *msg, ...)
     }
 }
 
+void checkasm_fail_signal(int signum)
+{
+#ifdef __GLIBC__
+    checkasm_fail_func("fatal signal %d: %s", signum, strsignal(signum));
+#else
+    checkasm_fail_func("fatal signal %d", signum);
+#endif
+}
+
 /* Get the benchmark context of the current function */
 CheckasmPerf *checkasm_get_perf_context(void)
 {
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index cfea868ff1..8a1df43ab6 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -102,6 +102,7 @@  struct CheckasmPerf;
 void *checkasm_check_func(void *func, const char *name, ...) av_printf_format(2, 3);
 int checkasm_bench_func(void);
 void checkasm_fail_func(const char *msg, ...) av_printf_format(1, 2);
+void checkasm_fail_signal(int signum);
 struct CheckasmPerf *checkasm_get_perf_context(void);
 void checkasm_report(const char *name, ...) av_printf_format(1, 2);