[asterisk-commits] dvossel: branch dvossel/test_api r234112 - /team/dvossel/test_api/main/test.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Dec 10 10:20:47 CST 2009


Author: dvossel
Date: Thu Dec 10 10:20:44 2009
New Revision: 234112

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=234112
Log:
beginning of test cli commands

Modified:
    team/dvossel/test_api/main/test.c

Modified: team/dvossel/test_api/main/test.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/test_api/main/test.c?view=diff&rev=234112&r1=234111&r2=234112
==============================================================================
--- team/dvossel/test_api/main/test.c (original)
+++ team/dvossel/test_api/main/test.c Thu Dec 10 10:20:44 2009
@@ -31,6 +31,7 @@
 #include "asterisk/logger.h"
 #include "asterisk/linkedlists.h"
 #include "asterisk/utils.h"
+#include "asterisk/cli.h"
 
 enum ast_test_result_state {
 	AST_TEST_NOT_RUN = 0,
@@ -69,25 +70,44 @@
 static int test_insert(struct ast_test *test);
 static struct ast_test *test_remove(ast_test_cb_t *cb);
 
-/* todohere remove, this is just for debuggin purposes during initial development */
-static void tests_print(void)
+static char *test_cli_show_registered(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	struct ast_test *cur = NULL;
-	AST_LIST_LOCK(&tests);
-	AST_LIST_TRAVERSE_SAFE_BEGIN(&tests, cur, entry) {
-		ast_log(LOG_NOTICE, "Name %s Catagory %s \n", cur->name, cur->catagory);
-	}
-	AST_LIST_TRAVERSE_SAFE_END;
-	AST_LIST_UNLOCK(&tests);
-}
+	int count = 0;
+
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "tests show registered";
+		e->usage =
+			"Usage: iax2 show registered\n"
+			"       Shows current registered tests\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;
+	case CLI_HANDLER:
+		AST_LIST_LOCK(&tests);
+		AST_LIST_TRAVERSE_SAFE_BEGIN(&tests, cur, entry) {
+			ast_cli(a->fd, "Name %s Catagory %s \n", cur->name, cur->catagory);
+			count ++;
+		}
+		AST_LIST_TRAVERSE_SAFE_END;
+		AST_LIST_UNLOCK(&tests);
+		ast_cli(a->fd, "%d Tests Registered\n", count);
+
+	default:
+		return NULL;
+	}
+}
+
+/* CLI commands */
+static struct ast_cli_entry test_cli[] = {
+	AST_CLI_DEFINE(test_cli_show_registered,           "show registered tests"),
+};
 
 int ast_test_init()
 {
-	//todohere register cli commands?!
-	//todohere remove these tests, they are just to verify list order, registration, and removal
-
-	tests_print();
-	//todohere end of tests
+	/* Register cli commands */
+	ast_cli_register_multiple(test_cli, ARRAY_LEN(test_cli));
 
 	return 0;
 }




More information about the asterisk-commits mailing list