summaryrefslogtreecommitdiff
path: root/test/test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/test.c')
-rw-r--r--test/test.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/test.c b/test/test.c
new file mode 100644
index 0000000..ec6f6fb
--- /dev/null
+++ b/test/test.c
@@ -0,0 +1,30 @@
+#include <re.h>
+#include <baresip.h>
+#include "test.h"
+
+
+static void timeout_handler(void *arg)
+{
+ int *err = arg;
+
+ warning("selftest: re_main() loop timed out -- test hung..\n");
+
+ *err = ETIMEDOUT;
+
+ re_cancel();
+}
+
+
+int re_main_timeout(uint32_t timeout)
+{
+ struct tmr tmr;
+ int err = 0;
+
+ tmr_init(&tmr);
+
+ tmr_start(&tmr, timeout * 1000, timeout_handler, &err);
+ re_main(NULL);
+
+ tmr_cancel(&tmr);
+ return err;
+}