[asterisk-commits] branch oej/moduletest - r7584 in
/team/oej/moduletest: Makefile cli.c loader.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Dec 21 14:22:37 CST 2005
Author: oej
Date: Wed Dec 21 14:22:34 2005
New Revision: 7584
URL: http://svn.digium.com/view/asterisk?rev=7584&view=rev
Log:
Work in progress...
The idea is to enable a CLI command that runs internal tests within
Asterisk modules, like SIP parsing tests, to make sure that complex
code work as expected after changes.
Modified:
team/oej/moduletest/Makefile
team/oej/moduletest/cli.c
team/oej/moduletest/loader.c
Modified: team/oej/moduletest/Makefile
URL: http://svn.digium.com/view/asterisk/team/oej/moduletest/Makefile?rev=7584&r1=7583&r2=7584&view=diff
==============================================================================
--- team/oej/moduletest/Makefile (original)
+++ team/oej/moduletest/Makefile Wed Dec 21 14:22:34 2005
@@ -80,6 +80,12 @@
# *CLI> show memory summary [filename]
#
MALLOC_DEBUG = #-include $(PWD)/include/asterisk/astmm.h
+
+# Enable testing if you want to run the internal code tests.
+# These are made for development testing, not for users
+# Enabling this will enable a new cli command named
+# "testmodule" that takes the module name as an argument
+ENABLE_TESTING = -DENABLE_CODE_TEST
# Where to install asterisk after compiling
# Default -> leave empty
@@ -330,6 +336,7 @@
ASTCFLAGS+= $(DEBUG_THREADS)
ASTCFLAGS+= $(TRACE_FRAMES)
ASTCFLAGS+= $(MALLOC_DEBUG)
+ASTCFLAGS+= $(ENABLE_TESTING)
ASTCFLAGS+= $(BUSYDETECT)
ASTCFLAGS+= $(OPTIONS)
ASTCFLAGS+= -fomit-frame-pointer
Modified: team/oej/moduletest/cli.c
URL: http://svn.digium.com/view/asterisk/team/oej/moduletest/cli.c?rev=7584&r1=7583&r2=7584&view=diff
==============================================================================
--- team/oej/moduletest/cli.c (original)
+++ team/oej/moduletest/cli.c Wed Dec 21 14:22:34 2005
@@ -277,6 +277,12 @@
" Shows Asterisk uptime information.\n"
" The seconds word returns the uptime in seconds only.\n";
+#ifdef ENABLE_CODE_TEST
+static char testmodule_help[] =
+"Usage: testmodule <modulename>\n"
+" If the module has a code test module, run it. (developers only)\n";
+#endif
+
static char *format_uptimestr(time_t timeval)
{
int years = 0, weeks = 0, days = 0, hours = 0, mins = 0, secs = 0;
@@ -413,6 +419,15 @@
}
#undef MODLIST_FORMAT
#undef MODLIST_FORMAT2
+
+static int handle_testmodule(int fd, int argc, char *argv[])
+{
+ if (argc <= 2)
+ return RESULT_SHOWUSAGE;
+
+ return RESULT_SUCCESS;
+}
+
static int handle_version(int fd, int argc, char *argv[])
{
@@ -968,6 +983,9 @@
{ { "soft", "hangup", NULL }, handle_softhangup, "Request a hangup on a given channel", softhangup_help, complete_ch_3 },
{ { "unload", NULL }, handle_unload, "Unload a dynamic module by name", unload_help, complete_fn },
{ { "group", "show", "channels", NULL }, group_show_channels, "Show active channels with group(s)", group_show_channels_help},
+#ifdef ENABLE_CODE_TEST
+ { { "testmodule", NULL }, handle_testmodule, "Test modules", testmodule_help },
+#endif
{ { NULL }, NULL, NULL, NULL }
};
Modified: team/oej/moduletest/loader.c
URL: http://svn.digium.com/view/asterisk/team/oej/moduletest/loader.c?rev=7584&r1=7583&r2=7584&view=diff
==============================================================================
--- team/oej/moduletest/loader.c (original)
+++ team/oej/moduletest/loader.c Wed Dec 21 14:22:34 2005
@@ -71,6 +71,9 @@
char *(*description)(void);
char *(*key)(void);
int (*reload)(void);
+#ifdef ENABLE_CODE_TEST
+ int (*codetest)(void);
+#endif
void *lib;
char resource[256];
struct module *next;
@@ -366,6 +369,12 @@
m->reload = dlsym(m->lib, "reload");
if (m->reload == NULL)
m->reload = dlsym(m->lib, "_reload");
+#ifdef ENABLE_CODE_TESTING
+ /* Check if there is a code testing function in this module */
+ m->codetest = dlsym(m->lib, "codetest");
+ if (m->codetest == NULL)
+ m->codetest = dlsym(m->lib, "_codetest");
+#endif
if (!m->key || !(key = (unsigned char *) m->key())) {
ast_log(LOG_WARNING, "Key routine returned NULL in module %s\n", fn);
More information about the asterisk-commits
mailing list