[svn-commits] dvossel: branch dvossel/test_api r234342 - in /team/dvossel/test_api: include...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Dec 10 17:06:37 CST 2009


Author: dvossel
Date: Thu Dec 10 17:06:33 2009
New Revision: 234342

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=234342
Log:
added ability for ast_test_execute to update cli in realtime

Modified:
    team/dvossel/test_api/include/asterisk/test.h
    team/dvossel/test_api/main/test.c

Modified: team/dvossel/test_api/include/asterisk/test.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/test_api/include/asterisk/test.h?view=diff&rev=234342&r1=234341&r2=234342
==============================================================================
--- team/dvossel/test_api/include/asterisk/test.h (original)
+++ team/dvossel/test_api/include/asterisk/test.h Thu Dec 10 17:06:33 2009
@@ -40,7 +40,11 @@
 
 #ifdef AST_TEST_FRAMEWORK
 
-#define AST_TEST_EXECUTE(test) test->result.state = test->cb(test->result.error, ARRAY_LEN(test->result.error))
+#include "asterisk/cli.h"
+
+#define AST_TEST_EXECUTE(test) \
+memset(test->result.error, 0, ARRAY_LEN(test->result.error)); \
+test->result.state = test->cb(test->result.error, ARRAY_LEN(test->result.error))
 
 /*!
  * \brief Generic test callback function
@@ -68,6 +72,7 @@
  * 
  * \param name of test to run (optional)
  * \param test catagory to run (optional)
+ * \param cli arguments for realtime cli test updates (optional)
  *
  * \return number of tests executed. 
  *
@@ -76,7 +81,7 @@
  * 2. When given only a catagory all tests within that catagory will execute.
  * 3. If given no name or catagory all registered tests will execute.
  */
-int ast_test_execute(const char *name, const char *catagory);
+int ast_test_execute(const char *name, const char *catagory, struct ast_cli_args *a);
 
 /*!
  * \brief Generate test results.

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=234342&r1=234341&r2=234342
==============================================================================
--- team/dvossel/test_api/main/test.c (original)
+++ team/dvossel/test_api/main/test.c Thu Dec 10 17:06:33 2009
@@ -120,7 +120,7 @@
 	return 0;
 }
 
-int ast_test_execute(const char *name, const char *catagory)
+int ast_test_execute(const char *name, const char *catagory, struct ast_cli_args *a)
 {
 	struct ast_test *test = NULL;
 	int mode = 0; /* 3 modes, 0 = run all, 1 = only by catagory, 2 = only by name and catagory */
@@ -146,6 +146,10 @@
 		}
 
 		if (execute) {
+			if (a) {
+				ast_cli(a->fd, "START %s/%s \n", test->catagory, test->name);
+			}
+
 			AST_TEST_EXECUTE(test);
 			last_results.count++;
 			if (test->result.state == AST_TEST_PASS) {
@@ -153,6 +157,11 @@
 			} else {
 				last_results.failed++;
 			}
+
+			if (a) {
+				ast_cli(a->fd, "END %s/%s Result: %s %s\n", test->catagory, test->name, test_result2str[test->result.state], test->result.error);
+			}
+
 		}
 	}
 	AST_LIST_TRAVERSE_SAFE_END;
@@ -360,14 +369,14 @@
 		}
 
 		if ((a->argc == 3) && !strcmp(a->argv[2], "all")) { /* run all registered tests */
-			ast_cli(a->fd, "Running all available tests...\n");
-			ast_test_execute(NULL, NULL);
+			ast_cli(a->fd, "Running all available tests...\n\n");
+			ast_test_execute(NULL, NULL, a);
 		} else if (a->argc == 4) { /* run only tests within a catagory */
-			ast_cli(a->fd, "Running all available tests matching catagory %s\n", a->argv[3]);
-			ast_test_execute(NULL, a->argv[3]);
+			ast_cli(a->fd, "Running all available tests matching catagory %s\n\n", a->argv[3]);
+			ast_test_execute(NULL, a->argv[3], a);
 		} else if (a->argc == 6) { /* run only a single test matching the catagory and name */
-			ast_cli(a->fd, "Running all available tests matching catagory %s and name %s\n", a->argv[5], a->argv[3]);
-			ast_test_execute(a->argv[5], a->argv[3]);
+			ast_cli(a->fd, "Running all available tests matching catagory %s and name %s\n\n", a->argv[5], a->argv[3]);
+			ast_test_execute(a->argv[5], a->argv[3], a);
 		} else {
 			return CLI_SHOWUSAGE;
 		}
@@ -375,7 +384,7 @@
 		if (!last_results.count) {
 			ast_cli(a->fd, "--- No Tests Found! ---\n");
 		}
-		ast_cli(a->fd, "%d Test(s) Executed  %d Passed  %d Failed\n", last_results.count, last_results.passed, last_results.failed);
+		ast_cli(a->fd, "\n%d Test(s) Executed  %d Passed  %d Failed\n", last_results.count, last_results.passed, last_results.failed);
 	default:
 		return NULL;
 	}




More information about the svn-commits mailing list