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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 14 12:24:56 CST 2009


Author: dvossel
Date: Mon Dec 14 12:24:54 2009
New Revision: 234697

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=234697
Log:
txt result formatting tweak

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=234697&r1=234696&r2=234697
==============================================================================
--- team/dvossel/test_api/main/test.c (original)
+++ team/dvossel/test_api/main/test.c Mon Dec 14 12:24:54 2009
@@ -26,11 +26,11 @@
 
 #include "asterisk.h"
 
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
+
+#ifdef TEST_FRAMEWORK
 #include "asterisk/_private.h"
-
 #include "asterisk/test.h"
-
-#ifdef TEST_FRAMEWORK
 #include "asterisk/logger.h"
 #include "asterisk/linkedlists.h"
 #include "asterisk/utils.h"
@@ -55,7 +55,7 @@
 
 struct ast_test_result {
 	enum ast_test_result_state state; /*! current test result state */
-	struct ast_str *error;             /*! optional error str to describe error result */
+	struct ast_str *error;            /*! optional error str to describe error result */
 	int time;                         /*! time in ms test took */
 };
 
@@ -64,18 +64,18 @@
 	char *catagory;      /*! test catagory */
 	char *summary;       /*! optional short summary of test */
 	char *description;   /*! optional brief detailed description of test */
-	struct ast_test_result result;  /*! stores the latest results */
-	ast_test_cb_t *cb;   /*! test call back function */
+	struct ast_test_result result;  /*! stores the latest execution results */
+	ast_test_cb_t *cb;   /*! test callback function */
 	AST_LIST_ENTRY(ast_test) entry;
 };
 
 static struct ast_test_execute_results {
 	int total_tests;  /* total number of tests, reguardless if they have been executed or not */
-	int total_passed; /* number of tests passed */
-	int total_failed; /* number of tests failed */
+	int total_passed; /* total number of executed tests passed */
+	int total_failed; /* total number of executed tests failed */
 	int total_time;   /* total time of all executed tests */
-	int last_passed;  /* number of tests passed during last execution */
-	int last_failed;  /* number of tests filed during last execution */
+	int last_passed;  /* number of passed tests during last execution */
+	int last_failed;  /* number of failed tests during last execution */
 	int last_time;    /* total time of the last test execution */
 } last_results = { 0 };
 
@@ -148,10 +148,10 @@
 	}
 
 	fprintf(f, "\n<test>\n");
-	fprintf(f, "<name>%s</name>\n", S_OR(test->name, "NA"));
-	fprintf(f, "<catagory>%s</catagory>\n", S_OR(test->catagory, "NA"));
-	fprintf(f, "<summary>%s</summary>\n", S_OR(test->summary, "NA"));
-	fprintf(f, "<description>%s</description>\n", S_OR(test->description, "NA"));
+	fprintf(f, "<name>%s</name>\n", test->name);
+	fprintf(f, "<catagory>%s</catagory>\n", test->catagory);
+	fprintf(f, "<summary>%s</summary>\n", test->summary);
+	fprintf(f, "<description>%s</description>\n", test->description);
 	fprintf(f, "<result>%s</result>\n", test_result2str[test->result.state]);
 	fprintf(f, "<error>%s</error>\n", S_OR(ast_str_buffer(test->result.error), "NA"));
 	fprintf(f, "<time>%d</time>\n", test->result.time);
@@ -164,13 +164,13 @@
 		return;
 	}
 
-	fprintf(f, "\nName: %s\n", S_OR(test->name, "NA"));
-	fprintf(f, "Catagory: %s\n", S_OR(test->catagory, "NA"));
-	fprintf(f, "Summary: %s\n", S_OR(test->summary, "NA"));
-	fprintf(f, "Description: %s\n", S_OR(test->description, "NA"));
-	fprintf(f, "Result: %s\n", test_result2str[test->result.state]);
-	fprintf(f, "Error Description: %s\n", S_OR(ast_str_buffer(test->result.error), "NA"));
-	fprintf(f, "Time: %d\n", test->result.time);
+	fprintf(f, "\nName:              %s\n", test->name);
+	fprintf(f,   "Catagory:          %s\n", test->catagory);
+	fprintf(f,   "Summary:           %s\n", test->summary);
+	fprintf(f,   "Description:       %s\n", test->description);
+	fprintf(f,   "Result:            %s\n", test_result2str[test->result.state]);
+	fprintf(f,   "Error Description: %s\n", S_OR(ast_str_buffer(test->result.error), "NA"));
+	fprintf(f,   "Time:              %d\n", test->result.time);
 
 }
 
@@ -408,7 +408,7 @@
 }
 
 /*!
- * \brief allocates a ast_test object.
+ * \brief allocates an ast_test object.
  */
 static struct ast_test *test_alloc(const char *name, const char *catagory, const char *summary, const char *description, ast_test_cb_t *cb)
 {
@@ -420,8 +420,8 @@
 
 	if (!(test->name = ast_strdup(name)) ||
 		 !(test->catagory = ast_strdup(catagory)) ||
-		 !(test->summary = ast_strdup(summary)) ||
-		 !(test->description = ast_strdup(description)) ||
+		 !(test->summary = ast_strdup(S_OR(summary, "NA"))) ||
+		 !(test->description = ast_strdup(S_OR(description, "NA"))) ||
 		 !(test->result.error = ast_str_create(128))) {
 
 		return test_free(test);
@@ -682,7 +682,7 @@
 
 	/* Register Sample Tests */
 	AST_TEST_REGISTER("sample_test_1", "main/test", "this is sample test 1", "for example purposes", sample_test1);
-	AST_TEST_REGISTER("sample_test_2", "main/test", "this is sample test 2", "for example purposes", sample_test2);
+	AST_TEST_REGISTER("sample_test_2", "main/test", NULL, NULL, sample_test2);
 
 	return 0;
 }




More information about the asterisk-commits mailing list