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

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Dec 17 14:56:19 CST 2009


Author: dvossel
Date: Thu Dec 17 14:56:17 2009
New Revision: 235515

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=235515
Log:
new AST_TEST_DEFINE macro for use when TEST_FRAMEWORK is not defined

Modified:
    team/dvossel/test_api/include/asterisk/test.h
    team/dvossel/test_api/tests/test_heap.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=235515&r1=235514&r2=235515
==============================================================================
--- team/dvossel/test_api/include/asterisk/test.h (original)
+++ team/dvossel/test_api/include/asterisk/test.h Thu Dec 17 14:56:17 2009
@@ -22,10 +22,10 @@
  * \brief Test Framework API
  */
 
-#ifdef TEST_FRAMEWORK
 #ifndef _AST_TEST_H_
 #define _AST_TEST_H_
 
+#ifdef TEST_FRAMEWORK
 #include "asterisk/cli.h"
 #include "asterisk/strings.h"
 #endif
@@ -41,11 +41,11 @@
        \param struct ast_test_args *args
 
    While these arguments are not visible they are passed to every test function
-   defined using the AST_TEST_DEFINE macros.
+   defined using the AST_TEST_DEFINE macro.
 
    Below is an example of how to define and write a test function.
 
-   AST_TEST_DEFINE_BEGIN(sample_test_cb) \\The name of the callback function
+   AST_TEST_DEFINE(sample_test_cb) \\The name of the callback function
    {                                     \\The the function's body 
       switch (cmd) {
       case TEST_INIT:
@@ -70,7 +70,6 @@
       }
       return res;                 \\ result must be of type enum ast_test_result_state
    }
-   AST_TEST_DEFINE_END            \\ defines the end of the test code.
 
    Every callback function is passed an ast_test_args object which contains
    an ast_str allowing the function to provide an optional short description of
@@ -101,18 +100,19 @@
 
 /*! Macros used for defining and registering a test */
 #ifdef TEST_FRAMEWORK
-#define AST_TEST_DEFINE_BEGIN(hdr) static enum ast_test_result_state hdr(struct ast_test_info *info, enum ast_test_command cmd, struct ast_test_args *args)
-#define AST_TEST_DEFINE_END /* no-op, TEST_FRAMEWORK is already defined */
+
+#define AST_TEST_DEFINE(hdr) static enum ast_test_result_state hdr(struct ast_test_info *info, enum ast_test_command cmd, struct ast_test_args *args)
 #define AST_TEST_REGISTER(cb) ast_test_register(cb)
 #define AST_TEST_UNREGISTER(cb) ast_test_unregister(cb)
+
 #else
-#define AST_TEST_DEFINE_BEGIN(hdr) #ifdef TEST_FRAMEWORK
-#define AST_TEST_DEFINE_END #endif
+
+#define AST_TEST_DEFINE(hdr) static enum ast_test_result_state attribute_unused hdr(struct ast_test_info *info, enum ast_test_command cmd, struct ast_test_args *args)
 #define AST_TEST_REGISTER(cb)
 #define AST_TEST_UNREGISTER(cb)
+
 #endif
 
-#ifdef TEST_FRAMEWORK
 enum ast_test_result_state {
 	AST_TEST_NOT_RUN = 0,
 	AST_TEST_PASS = 1,
@@ -141,6 +141,9 @@
 	const char *description;   /*! optional brief detailed description of test */
 };
 
+
+
+#ifdef TEST_FRAMEWORK
 /*!
  * \brief Generic test callback function
  *

Modified: team/dvossel/test_api/tests/test_heap.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/test_api/tests/test_heap.c?view=diff&rev=235515&r1=235514&r2=235515
==============================================================================
--- team/dvossel/test_api/tests/test_heap.c (original)
+++ team/dvossel/test_api/tests/test_heap.c Thu Dec 17 14:56:17 2009
@@ -36,7 +36,6 @@
 #include "asterisk/heap.h"
 #include "asterisk/test.h"
 
-#ifdef TEST_FRAMEWORK
 struct node {
 	long val;
 	size_t index;
@@ -55,9 +54,8 @@
 		return 1;
 	}
 }
-#endif
-
-AST_TEST_DEFINE_BEGIN(heap_test_1)
+
+AST_TEST_DEFINE(heap_test_1)
 {
 	struct ast_heap *h;
 	struct node *obj;
@@ -82,8 +80,6 @@
 		return AST_TEST_FAIL;
 	}
 
-	/* Pushing 1 2 3, and then popping 3 elements */
-
 	ast_heap_push(h, &nodes[0]);
 
 	ast_heap_push(h, &nodes[1]);
@@ -114,9 +110,8 @@
 
 	return AST_TEST_PASS;
 }
-AST_TEST_DEFINE_END
-
-AST_TEST_DEFINE_BEGIN(heap_test_2)
+
+AST_TEST_DEFINE(heap_test_2)
 {
 	struct ast_heap *h = NULL;
 	static const unsigned int one_million = 1000000;
@@ -125,7 +120,7 @@
 	unsigned int i = one_million;
 	long last = LONG_MAX;
 	long cur;
-	int res = AST_TEST_PASS;
+	enum ast_test_result_state res = AST_TEST_PASS;
 
 	switch (cmd) {
 	case TEST_INIT:
@@ -186,8 +181,6 @@
 
 	return res;
 }
-AST_TEST_DEFINE_END
-
 
 static int unload_module(void)
 {




More information about the svn-commits mailing list