diff options
author | Alfred E. Heggestad <aeh@db.org> | 2014-04-12 16:04:48 +0200 |
---|---|---|
committer | Alfred E. Heggestad <aeh@db.org> | 2014-04-12 16:04:48 +0200 |
commit | c789e9a72c9f65f8f598823da0adb82cde2b3bce (patch) | |
tree | dd91fb42f686894613436744d5cfb4e464a4d369 /modules/selftest/selftest.c | |
parent | cfa7d320a82be9c85ec31235de4c7b79336bcbe2 (diff) |
selftest: new module for testing baresip core
the selftest module is using the public API of the
Baresip core (in baresip.h) to verify the expected
behaviour and to test various protocol scenarios.
the module can be loaded with the 'module' directive
or 'module_tmp' directive:
module_tmp selftest.so
OR:
module selftest.so
Diffstat (limited to 'modules/selftest/selftest.c')
-rw-r--r-- | modules/selftest/selftest.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/modules/selftest/selftest.c b/modules/selftest/selftest.c new file mode 100644 index 0000000..87e89d3 --- /dev/null +++ b/modules/selftest/selftest.c @@ -0,0 +1,75 @@ +/** + * @file selftest.c Selftest for Baresip core + * + * Copyright (C) 2010 Creytiv.com + */ +#include <re.h> +#include <baresip.h> +#include "selftest.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; +} + + +static int module_init(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; + + re_printf("\x1b[32mselftest passed successfully\x1b[;m\n"); + + return 0; +} + + +static int module_close(void) +{ + return 0; +} + + +const struct mod_export DECL_EXPORTS(selftest) = { + "selftest", + "application", + module_init, + module_close +}; |