[asterisk-commits] branch russell/codetest - r7625 /team/russell/codetest/codetest.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Dec 24 22:07:14 CST 2005


Author: russell
Date: Sat Dec 24 22:07:13 2005
New Revision: 7625

URL: http://svn.digium.com/view/asterisk?rev=7625&view=rev
Log:
correctly handle an invalid specified test

Modified:
    team/russell/codetest/codetest.c

Modified: team/russell/codetest/codetest.c
URL: http://svn.digium.com/view/asterisk/team/russell/codetest/codetest.c?rev=7625&r1=7624&r2=7625&view=diff
==============================================================================
--- team/russell/codetest/codetest.c (original)
+++ team/russell/codetest/codetest.c Sat Dec 24 22:07:13 2005
@@ -250,6 +250,7 @@
 	struct ast_codetest *test;
 	char *testname = NULL;
 	int res = 0;
+	int test_executed = 0;
 	int test_argc = 0;
 	char **test_argv = NULL;
 
@@ -274,18 +275,28 @@
 	}
 
 	AST_LIST_TRAVERSE(&tf->codetests, test, list) {
-		ast_cli(fd, "Executing test '%s' for file '%s' ...\n", test->testname, test->filename);
-		if (!ast_strlen_zero(testname) && !strcmp(test->testname, testname)) {
+		if (!ast_strlen_zero(testname)) {
+			if (!strcmp(test->testname, testname)) {
+				ast_cli(fd, "Executing test '%s' for file '%s' ...\n", test->testname, test->filename);
+				res = test->codetest(fd, test_argc, test_argv);
+				check_test_result(fd, test, res);
+				test_executed = 1;
+				break;
+			}
+		} else {
+			ast_cli(fd, "Executing test '%s' for file '%s' ...\n", test->testname, test->filename);
 			res = test->codetest(fd, test_argc, test_argv);
-			check_test_result(fd, test, res);
-			break;
-		} else {
-			res = test->codetest(fd, test_argc, test_argv);
+			test_executed = 1;
 			check_test_result(fd, test, res);
 		}
 	}
 
 	AST_LIST_UNLOCK(&testfile_list);
+
+	if (!test_executed && !ast_strlen_zero(testname)) {
+		ast_cli(fd, "Test '%s' not found for file '%s'!\n", testname, argv[2]);
+		return RESULT_FAILURE;
+	}
 
 	return RESULT_SUCCESS;
 }



More information about the asterisk-commits mailing list