summaryrefslogtreecommitdiff
path: root/test/test.c
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2015-08-09 15:28:08 +0200
committerAlfred E. Heggestad <aeh@db.org>2015-08-09 15:28:08 +0200
commit0535a3244acc2a6c096703090b467e60e630cf60 (patch)
treed5ea6873d5c092c7494818581253a7d03b4c14e0 /test/test.c
parent7d43d386d03047f4f1a3b5abbb4f4ecf81eb650b (diff)
selftest: new binary
- move selftest code from module/selftest to test/. - create a new binary called 'selftest' - the selftest is testing the Baresip Core only
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;
+}