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

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Dec 10 18:34:40 CST 2009


Author: dvossel
Date: Thu Dec 10 18:34:37 2009
New Revision: 234371

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=234371
Log:
ast_test_execute now records the amount of time each test took

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=234371&r1=234370&r2=234371
==============================================================================
--- team/dvossel/test_api/include/asterisk/test.h (original)
+++ team/dvossel/test_api/include/asterisk/test.h Thu Dec 10 18:34:37 2009
@@ -76,10 +76,6 @@
 
 #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
  *

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=234371&r1=234370&r2=234371
==============================================================================
--- team/dvossel/test_api/main/test.c (original)
+++ team/dvossel/test_api/main/test.c Thu Dec 10 18:34:37 2009
@@ -120,6 +120,16 @@
 	return 0;
 }
 
+static void __test_execute(struct ast_test *test)
+{
+	struct timeval begin;
+
+	memset(test->result.error, 0, ARRAY_LEN(test->result.error));
+	begin = ast_tvnow();
+	test->result.state = test->cb(test->result.error, ARRAY_LEN(test->result.error));
+	test->result.time = ast_tvdiff_ms(ast_tvnow(), begin);
+}
+
 int ast_test_execute(const char *name, const char *catagory, struct ast_cli_args *a)
 {
 	struct ast_test *test = NULL;
@@ -147,10 +157,10 @@
 
 		if (execute) {
 			if (a) {
-				ast_cli(a->fd, "START %s/%s \n", test->catagory, test->name);
-			}
-
-			AST_TEST_EXECUTE(test);
+				ast_cli(a->fd, "START  %s/%s \n", test->catagory, test->name);
+			}
+
+			__test_execute(test);
 			last_results.count++;
 			if (test->result.state == AST_TEST_PASS) {
 				last_results.passed++;
@@ -159,7 +169,7 @@
 			}
 
 			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_cli(a->fd, "END    %s/%s Time: %dms Result: %s %s\n", test->catagory, test->name, test->result.time, test_result2str[test->result.state], test->result.error);
 			}
 
 		}
@@ -497,6 +507,7 @@
 /* Sample Test */
 AST_TEST_DEFINE(sample_test1,
 {
+	sleep(1);
 	return AST_TEST_FAIL;
 })
 




More information about the svn-commits mailing list