summaryrefslogtreecommitdiff
path: root/test/main.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/main.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/main.c')
-rw-r--r--test/main.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/test/main.c b/test/main.c
new file mode 100644
index 0000000..c32cd4b
--- /dev/null
+++ b/test/main.c
@@ -0,0 +1,86 @@
+/**
+ * @file test/main.c Selftest for Baresip core
+ *
+ * Copyright (C) 2010 Creytiv.com
+ */
+#include <re.h>
+#include <baresip.h>
+#include "test.h"
+
+
+static int run_tests(void)
+{
+ int err;
+
+ err = test_cmd();
+ if (err)
+ return err;
+
+ err = test_ua_alloc();
+ if (err)
+ return err;
+
+ err = test_uag_find_param();
+ if (err)
+ return err;
+
+ err = test_ua_register();
+ if (err)
+ return err;
+
+ return 0;
+}
+
+
+int main(void)
+{
+ struct config *config;
+ int err;
+
+ err = libre_init();
+ if (err)
+ return err;
+
+ re_printf("running test..\n");
+
+ /* note: run SIP-traffic on localhost */
+ config = conf_config();
+ if (!config) {
+ err = ENOENT;
+ goto out;
+ }
+ str_ncpy(config->sip.local, "127.0.0.1:0", sizeof(config->sip.local));
+
+ /* XXX: needed for ua tests */
+ err = ua_init("test", true, true, false, false);
+ if (err)
+ goto out;
+
+ err = run_tests();
+ if (err)
+ goto out;
+
+#if 1
+ ua_stop_all(false);
+ err = re_main_timeout(5);
+ if (err)
+ goto out;
+#endif
+
+ re_printf("\x1b[32mOK. selftest passed successfully\x1b[;m\n");
+
+ out:
+ if (err) {
+ warning("test failed (%m)\n", err);
+ re_printf("%H\n", re_debug, 0);
+ }
+ ua_stop_all(true);
+ ua_close();
+
+ libre_close();
+
+ tmr_debug();
+ mem_debug();
+
+ return err;
+}