aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/msgb/msgb_test.c31
-rw-r--r--tests/testsuite.at2
2 files changed, 32 insertions, 1 deletions
diff --git a/tests/msgb/msgb_test.c b/tests/msgb/msgb_test.c
index 75925095..260aca54 100644
--- a/tests/msgb/msgb_test.c
+++ b/tests/msgb/msgb_test.c
@@ -23,6 +23,7 @@
#include <osmocom/core/logging.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/msgb.h>
+#include <setjmp.h>
#include <errno.h>
@@ -34,6 +35,36 @@
abort(); \
}
+static jmp_buf jmp_env;
+static int jmp_env_valid = 0;
+static void osmo_panic_raise(const char *fmt, va_list args)
+{
+ /*
+ * The args can include pointer values which are not suitable for
+ * regression testing. So just write the (hopefully constant) format
+ * string to stdout and write the full message to stderr.
+ */
+ printf("%s", fmt);
+ vfprintf(stderr, fmt, args);
+ if (!jmp_env_valid)
+ abort();
+ longjmp(jmp_env, 1);
+}
+
+/* Note that this does not nest */
+#define OSMO_PANIC_TRY(pE) (osmo_panic_try(pE, setjmp(jmp_env)))
+
+static int osmo_panic_try(volatile int *exception, int setjmp_result)
+{
+ jmp_env_valid = setjmp_result == 0;
+ *exception = setjmp_result;
+
+ if (setjmp_result)
+ fprintf(stderr, "Exception caught: %d\n", setjmp_result);
+
+ return *exception == 0;
+}
+
static void test_msgb_api()
{
struct msgb *msg = msgb_alloc_headroom(4096, 128, "data");
diff --git a/tests/testsuite.at b/tests/testsuite.at
index d9bd3236..9cda1de0 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -36,7 +36,7 @@ AT_CLEANUP
AT_SETUP([msgb])
AT_KEYWORDS([msgb])
cat $abs_srcdir/msgb/msgb_test.ok > expout
-AT_CHECK([$abs_top_builddir/tests/msgb/msgb_test], [0], [expout])
+AT_CHECK([$abs_top_builddir/tests/msgb/msgb_test], [0], [expout], [ignore])
AT_CLEANUP
if ENABLE_MSGFILE