[asterisk-commits] branch oej/moduletest - r7585 in
/team/oej/moduletest: ./ channels/ include/a...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Dec 21 15:45:53 CST 2005
Author: oej
Date: Wed Dec 21 15:45:49 2005
New Revision: 7585
URL: http://svn.digium.com/view/asterisk?rev=7585&view=rev
Log:
Test framework, not tested yet ;-)
Modified:
team/oej/moduletest/channels/chan_sip.c
team/oej/moduletest/cli.c
team/oej/moduletest/include/asterisk/module.h
team/oej/moduletest/loader.c
Modified: team/oej/moduletest/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/moduletest/channels/chan_sip.c?rev=7585&r1=7584&r2=7585&view=diff
==============================================================================
--- team/oej/moduletest/channels/chan_sip.c (original)
+++ team/oej/moduletest/channels/chan_sip.c Wed Dec 21 15:45:49 2005
@@ -13234,3 +13234,11 @@
}
+/*--------------- Test functions -------------------*/
+#ifdef ENABLE_CODE_TEST
+int codetest(int fd)
+{
+ ast_cli(fd, "Testing chan_sip functions.... \n");
+ return RESULT_SUCCESS;
+}
+#endif
Modified: team/oej/moduletest/cli.c
URL: http://svn.digium.com/view/asterisk/team/oej/moduletest/cli.c?rev=7585&r1=7584&r2=7585&view=diff
==============================================================================
--- team/oej/moduletest/cli.c (original)
+++ team/oej/moduletest/cli.c Wed Dec 21 15:45:49 2005
@@ -420,13 +420,16 @@
#undef MODLIST_FORMAT
#undef MODLIST_FORMAT2
+#ifdef ENABLE_CODE_TEST
static int handle_testmodule(int fd, int argc, char *argv[])
{
- if (argc <= 2)
- return RESULT_SHOWUSAGE;
-
- return RESULT_SUCCESS;
-}
+ if (argc < 2)
+ return RESULT_SHOWUSAGE;
+ ast_cli(fd, "Testing module %s \n", argv[1]);
+ ast_test_module(argv[1], fd);
+ return RESULT_SUCCESS;
+}
+#endif
static int handle_version(int fd, int argc, char *argv[])
Modified: team/oej/moduletest/include/asterisk/module.h
URL: http://svn.digium.com/view/asterisk/team/oej/moduletest/include/asterisk/module.h?rev=7585&r1=7584&r2=7585&view=diff
==============================================================================
--- team/oej/moduletest/include/asterisk/module.h (original)
+++ team/oej/moduletest/include/asterisk/module.h Wed Dec 21 15:45:49 2005
@@ -225,6 +225,17 @@
* progress, and 2 if the specfied module was found and reloaded.
*/
int ast_module_reload(const char *name);
+
+
+#ifdef ENABLE_CODE_TEST
+/*! \brief Tests a module
+ * \param name the name of the module to test
+ * \param fd File handle for output
+ * This is used by the testmodule application.
+ * For developer use only, really.
+*/
+int ast_test_module(const char *name, int fd);
+#endif
/*!
* \brief Match modules names for the Asterisk cli.
Modified: team/oej/moduletest/loader.c
URL: http://svn.digium.com/view/asterisk/team/oej/moduletest/loader.c?rev=7585&r1=7584&r2=7585&view=diff
==============================================================================
--- team/oej/moduletest/loader.c (original)
+++ team/oej/moduletest/loader.c Wed Dec 21 15:45:49 2005
@@ -43,6 +43,7 @@
#include "asterisk/enum.h"
#include "asterisk/rtp.h"
#include "asterisk/lock.h"
+#include "asterisk/cli.h"
#ifdef DLFCNCOMPAT
#include "asterisk/dlfcn-compat.h"
#else
@@ -72,7 +73,7 @@
char *(*key)(void);
int (*reload)(void);
#ifdef ENABLE_CODE_TEST
- int (*codetest)(void);
+ int (*codetest)(int fd);
#endif
void *lib;
char resource[256];
@@ -206,6 +207,34 @@
return ret;
}
+#ifdef ENABLE_CODE_TEST
+int ast_test_module(const char *name, int fd)
+{
+ struct module *m;
+ int (*codetest)(int fd);
+
+ ast_mutex_lock(&modlock);
+ m = module_list;
+ while(m) {
+ if (!strcasecmp(name, m->resource)) {
+ codetest = m->codetest;
+ if (codetest) {
+ ast_cli(fd, "Found module %s. Calling test functions. \n\n", name);
+ codetest(fd);
+ break;
+ } else
+ ast_cli(fd, "Module %s has no test functions. \n\n", name);
+ }
+ m = m->next;
+ }
+ if (!m)
+ ast_cli(fd, "Module %s not found \n", name);
+ ast_mutex_unlock(&modlock);
+
+ return RESULT_SUCCESS;
+}
+#endif
+
int ast_module_reload(const char *name)
{
struct module *m;
@@ -269,6 +298,8 @@
ast_mutex_unlock(&reloadlock);
return reloaded;
}
+
+
static int __load_resource(const char *resource_name, const struct ast_config *cfg)
{
More information about the asterisk-commits
mailing list