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

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Dec 16 14:47:19 CST 2009


Author: dvossel
Date: Wed Dec 16 14:47:17 2009
New Revision: 235343

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=235343
Log:
spelling change, s/catagory/category

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=235343&r1=235342&r2=235343
==============================================================================
--- team/dvossel/test_api/include/asterisk/test.h (original)
+++ team/dvossel/test_api/include/asterisk/test.h Wed Dec 16 14:47:17 2009
@@ -128,47 +128,47 @@
  * \brief registers a test with the test framework
  *
  * \param name of test (required)
- * \param test catagory (required)
+ * \param test category (required)
  * \param test summary (optional)
  * \param test description (optional)
  * \param test callback function (required)
  *
  * \return 0 for pass, -1 for failure
  */
-int ast_test_register(const char *name, const char *catagory, const char *summary, const char *description, ast_test_cb_t *cb);
+int ast_test_register(const char *name, const char *category, const char *summary, const char *description, ast_test_cb_t *cb);
 
 /*!
  * \brief Executes registered unit tests
  * 
  * \param name of test to run (optional)
- * \param test catagory to run (optional)
+ * \param test category to run (optional)
  * \param cli arguments for realtime cli test updates (optional)
  *
  * \return number of tests executed. 
  *
  * \note This function has three modes of operation
- * 1. When given a name and catagory, a matching individual test will execute if found.
- * 2. When given only a catagory all matching tests within that catagory will execute.
- * 3. If given no name or catagory all registered tests will execute.
+ * 1. When given a name and category, a matching individual test will execute if found.
+ * 2. When given only a category all matching tests within that category will execute.
+ * 3. If given no name or category all registered tests will execute.
  */
-int ast_test_execute(const char *name, const char *catagory, struct ast_cli_args *a);
+int ast_test_execute(const char *name, const char *category, struct ast_cli_args *a);
 
 /*!
  * \brief Generate test results.
  * 
  * \param name of test result to generate (optional)
- * \param test catagory to generate (optional)
+ * \param test category to generate (optional)
  * \param path to xml file to generate. (optional)
  * \param path to txt file to generate, (optional)
  *
  * \return 0 if results were generated, -1 if error  
  *
  * \note This function has three modes of operation.
- * 1. When given both a name and catagory, results will be generated for that single test. 
- * 2. When given only a catagory, results for every test within the catagory will be generated.
- * 3. When given no name or catagory, results for every registered test will be generated.
+ * 1. When given both a name and category, results will be generated for that single test. 
+ * 2. When given only a category, results for every test within the category will be generated.
+ * 3. When given no name or category, results for every registered test will be generated.
  * 
  * In order for the results to be generated, an xml and or txt file path must be provided.
  */
-int ast_test_generate_results(const char *name, const char *catagory, const char *xml_path, const char *txt_path);
+int ast_test_generate_results(const char *name, const char *category, const char *xml_path, const char *txt_path);
 #endif

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=235343&r1=235342&r2=235343
==============================================================================
--- team/dvossel/test_api/main/test.c (original)
+++ team/dvossel/test_api/main/test.c Wed Dec 16 14:47:17 2009
@@ -56,8 +56,8 @@
 
 /*! holds all the information pertaining to a single defined test */
 struct ast_test {
-	char *name;          /*! name of test, unique to catagory */
-	char *catagory;      /*! test catagory */
+	char *name;          /*! name of test, unique to category */
+	char *category;      /*! test category */
 	char *summary;       /*! optional short summary of test */
 	char *description;   /*! optional brief detailed description of test */
 	struct ast_test_result result;  /*! stores the latest execution results */
@@ -80,23 +80,23 @@
 static AST_LIST_HEAD_STATIC(tests, ast_test);
 
 /*! static function prototypes */
-static struct ast_test *test_alloc(const char *name, const char *catagory, const char *summary, const char *description, ast_test_cb_t *cb);
+static struct ast_test *test_alloc(const char *name, const char *category, const char *summary, const char *description, ast_test_cb_t *cb);
 static struct ast_test *test_free(struct ast_test *test);
 static int test_insert(struct ast_test *test);
 static struct ast_test *test_remove(ast_test_cb_t *cb);
 static int test_cat_cmp(const char *cat1, const char *cat2);
 
-int ast_test_register(const char *name, const char *catagory, const char *summary, const char *description, ast_test_cb_t *cb)
+int ast_test_register(const char *name, const char *category, const char *summary, const char *description, ast_test_cb_t *cb)
 {
 	struct ast_test *test;
 
 	/* verify data.  Name, Catagory, and cb _MUST_ be present to register a test */
-	if (ast_strlen_zero(name) || ast_strlen_zero(catagory) || !cb) {
+	if (ast_strlen_zero(name) || ast_strlen_zero(category) || !cb) {
 		return -1;
 	}
 
 	/* create test object */
-	if (!(test = test_alloc(name, catagory, summary, description, cb))) {
+	if (!(test = test_alloc(name, category, summary, description, cb))) {
 		return -1;
 	}
 
@@ -152,7 +152,7 @@
 
 	fprintf(f, "\n<test>\n");
 	fprintf(f, "<name>%s</name>\n", test->name);
-	fprintf(f, "<catagory>%s</catagory>\n", test->catagory);
+	fprintf(f, "<category>%s</category>\n", test->category);
 	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]);
@@ -168,7 +168,7 @@
 	}
 
 	fprintf(f, "\nName:              %s\n", test->name);
-	fprintf(f,   "Catagory:          %s\n", test->catagory);
+	fprintf(f,   "Catagory:          %s\n", test->category);
 	fprintf(f,   "Summary:           %s\n", test->summary);
 	fprintf(f,   "Description:       %s\n", test->description);
 	fprintf(f,   "Result:            %s\n", test_result2str[test->result.state]);
@@ -176,15 +176,15 @@
 	fprintf(f,   "Time:              %d\n", test->result.time);
 }
 
-int ast_test_execute(const char *name, const char *catagory, struct ast_cli_args *a)
+int ast_test_execute(const char *name, const char *category, struct ast_cli_args *a)
 {
 	char result_buf[32] = { 0 };
 	struct ast_test *test = NULL;
-	int mode = 0; /* 3 modes, 0 = run all, 1 = only by catagory, 2 = only by name and catagory */
+	int mode = 0; /* 3 modes, 0 = run all, 1 = only by category, 2 = only by name and category */
 	int execute = 0;
 	int res = 0;
 
-	if (!ast_strlen_zero(catagory)) {
+	if (!ast_strlen_zero(category)) {
 		if (!ast_strlen_zero(name)) {
 			mode = 2;
 		} else {
@@ -199,15 +199,15 @@
 
 		execute = 0;
 		if ((!mode) ||
-			((mode == 1) && !(test_cat_cmp(test->catagory, catagory))) ||
-			((mode == 2) && !(strcmp(test->catagory, catagory)) && !(strcmp(test->name, name)))) {
+			((mode == 1) && !(test_cat_cmp(test->category, category))) ||
+			((mode == 2) && !(strcmp(test->category, category)) && !(strcmp(test->name, name)))) {
 
 			execute = 1;
 		}
 
 		if (execute) {
 			if (a) {
-				ast_cli(a->fd, "START  %s/%s \n", test->catagory, test->name);
+				ast_cli(a->fd, "START  %s/%s \n", test->category, test->name);
 			}
 
 			/* execute the test and save results */
@@ -228,7 +228,7 @@
 					0,
 					sizeof(result_buf));
 				ast_cli(a->fd, "END    %s/%s Time: %dms Result: %s %s\n",
-					test->catagory,
+					test->category,
 					test->name,
 					test->result.time,
 					result_buf,
@@ -255,9 +255,9 @@
 	return res;
 }
 
-int ast_test_generate_results(const char *name, const char *catagory, const char *xml_path, const char *txt_path)
-{
-	char mode = 0;  /* 0 generate all, 1 generate by catagory only, 2 generate by name and catagory */
+int ast_test_generate_results(const char *name, const char *category, const char *xml_path, const char *txt_path)
+{
+	char mode = 0;  /* 0 generate all, 1 generate by category only, 2 generate by name and category */
 	FILE *f_xml = NULL, *f_txt = NULL;
 	int res = 0;
 	struct ast_test *test = NULL;
@@ -268,7 +268,7 @@
 	}
 
 	/* define what mode is to be used */
-	if (!ast_strlen_zero(catagory)) {
+	if (!ast_strlen_zero(category)) {
 		if (!ast_strlen_zero(name)) {
 			mode = 2;
 		} else {
@@ -338,7 +338,7 @@
 }
 
 /*!
- * \brief adds test to container sorted first by catagory then by name
+ * \brief adds test to container sorted first by category then by name
  *
  * \return 0 on success, -1 on failure
  */
@@ -354,11 +354,11 @@
 	 * comparisons on every item within the list to insert in sorted order. */
 	AST_LIST_LOCK(&tests);
 	AST_LIST_TRAVERSE_SAFE_BEGIN(&tests, cur, entry) {
-		if ((i = strcmp(test->catagory, cur->catagory)) < 0) {
+		if ((i = strcmp(test->category, cur->category)) < 0) {
 			AST_LIST_INSERT_BEFORE_CURRENT(test, entry);
 			inserted = 1;
 			break;
-		} else if (!i) {  /* same catagory, now insert by name within that catagory*/
+		} else if (!i) {  /* same category, now insert by name within that category*/
 			if ((i = strcmp(test->name, cur->name)) < 0) {
 				AST_LIST_INSERT_BEFORE_CURRENT(test, entry);
 				inserted = 1;
@@ -389,12 +389,11 @@
  */
 static struct ast_test *test_remove(ast_test_cb_t *cb)
 {
-	struct ast_test *cur = NULL, *test = NULL;
+	struct ast_test *cur = NULL;
 
 	AST_LIST_LOCK(&tests);
 	AST_LIST_TRAVERSE_SAFE_BEGIN(&tests, cur, entry) {
 		if (cur->cb == cb) {
-			test = cur;
 			AST_LIST_REMOVE_CURRENT(entry);
 			break;
 		}
@@ -402,7 +401,7 @@
 	AST_LIST_TRAVERSE_SAFE_END;
 	AST_LIST_UNLOCK(&tests);
 
-	return test;
+	return cur;
 }
 
 /*!
@@ -415,7 +414,7 @@
 	}
 
 	ast_free(test->name);
-	ast_free(test->catagory);
+	ast_free(test->category);
 	ast_free(test->summary);
 	ast_free(test->description);
 	ast_free(test->result.error);
@@ -452,7 +451,7 @@
 /*!
  * \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)
+static struct ast_test *test_alloc(const char *name, const char *category, const char *summary, const char *description, ast_test_cb_t *cb)
 {
 	struct ast_test *test;
 
@@ -461,7 +460,7 @@
 	}
 
 	if (!(test->name = ast_strdup(name)) ||
-		 !(test->catagory = ast_strdup(catagory)) ||
+		 !(test->category = ast_strdup(category)) ||
 		 !(test->summary = ast_strdup(S_OR(summary, "NA"))) ||
 		 !(test->description = ast_strdup(S_OR(description, "NA"))) ||
 		 !(test->result.error = ast_str_create(128))) {
@@ -478,7 +477,7 @@
 static char *test_cli_show_registered(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 #define FORMAT "%-15s %-20s %-30s %-10s\n"
-	static const char * const option1[] = { "all", "catagory", NULL };
+	static const char * const option1[] = { "all", "category", NULL };
 	static const char * const option2[] = { "name", NULL };
 	struct ast_test *test = NULL;
 	int count = 0;
@@ -489,10 +488,10 @@
 		e->usage =
 			"Usage: 'test show registered' can be used in three ways.\n"
 			"       1. 'test show registered all' shows all registered tests\n"
-			"       2. 'test show registered catagory [test catagory]' shows all tests in the given\n"
-			"          catagory.\n"
-			"       3. 'test show registered catagory [test catagory] name [test name]' shows all\n"
-			"           tests in a given catagory matching a given name\n";
+			"       2. 'test show registered category [test category]' shows all tests in the given\n"
+			"          category.\n"
+			"       3. 'test show registered category [test category] name [test name]' shows all\n"
+			"           tests in a given category matching a given name\n";
 		return NULL;
 	case CLI_GENERATE:
 		if (a->pos == 3) {
@@ -512,10 +511,10 @@
 		AST_LIST_LOCK(&tests);
 		AST_LIST_TRAVERSE_SAFE_BEGIN(&tests, test, entry) {
 			if ((a->argc == 4) ||
-				 ((a->argc == 5) && !test_cat_cmp(test->catagory, a->argv[4])) ||
-				 ((a->argc == 7) && !strcmp(test->catagory, a->argv[4]) && !strcmp(test->name, a->argv[6]))) {
-
-				ast_cli(a->fd, FORMAT, test->name, test->catagory, test->summary, test_result2str[test->result.state]);
+				 ((a->argc == 5) && !test_cat_cmp(test->category, a->argv[4])) ||
+				 ((a->argc == 7) && !strcmp(test->category, a->argv[4]) && !strcmp(test->name, a->argv[6]))) {
+
+				ast_cli(a->fd, FORMAT, test->name, test->category, test->summary, test_result2str[test->result.state]);
 				count ++;
 			}
 		}
@@ -531,7 +530,7 @@
 
 static char *test_cli_execute_registered(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	static const char * const option1[] = { "all", "catagory", NULL };
+	static const char * const option1[] = { "all", "category", NULL };
 	static const char * const option2[] = { "name", NULL };
 	switch (cmd) {
 	case CLI_INIT:
@@ -539,10 +538,10 @@
 		e->usage =
 			"Usage: test execute can be used in three ways.\n"
 			"       1. 'test execute all' runs all registered tests\n"
-			"       2. 'test execute catagory [test catagory]' runs all tests in the given\n"
-			"          catagory.\n"
-			"       3. 'test execute catagory [test catagory] name [test name]' runs all\n"
-			"           tests in a given catagory matching a given name\n";
+			"       2. 'test execute category [test category]' runs all tests in the given\n"
+			"          category.\n"
+			"       3. 'test execute category [test category] name [test name]' runs all\n"
+			"           tests in a given category matching a given name\n";
 		return NULL;
 	case CLI_GENERATE:
 		if (a->pos == 2) {
@@ -561,11 +560,11 @@
 		if ((a->argc == 3) && !strcmp(a->argv[2], "all")) { /* run all registered tests */
 			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\n", a->argv[3]);
+		} else if (a->argc == 4) { /* run only tests within a category */
+			ast_cli(a->fd, "Running all available tests matching category %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\n", a->argv[5], a->argv[3]);
+		} else if (a->argc == 6) { /* run only a single test matching the category and name */
+			ast_cli(a->fd, "Running all available tests matching category %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;
@@ -641,7 +640,7 @@
 						result_buf,
 						"  ",
 						test->name,
-						test->catagory,
+						test->category,
 						(test->result.state == AST_TEST_FAIL) ? S_OR(ast_str_buffer(test->result.error), "Not Avaliable") : "");
 				}
 			}




More information about the svn-commits mailing list