[svn-commits] mmichelson: branch group/dns_naptr r433323 - /team/group/dns_naptr/tests/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Mar 24 09:50:33 CDT 2015


Author: mmichelson
Date: Tue Mar 24 09:50:30 2015
New Revision: 433323

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=433323
Log:
Make the nominal NAPTR test actually test stuff.

The nominal test now ensures that the returned NAPTR
records are parsed with the expected values and that they
are sorted in the expected order.


Modified:
    team/group/dns_naptr/tests/test_dns_naptr.c

Modified: team/group/dns_naptr/tests/test_dns_naptr.c
URL: http://svnview.digium.com/svn/asterisk/team/group/dns_naptr/tests/test_dns_naptr.c?view=diff&rev=433323&r1=433322&r2=433323
==============================================================================
--- team/group/dns_naptr/tests/test_dns_naptr.c (original)
+++ team/group/dns_naptr/tests/test_dns_naptr.c Tue Mar 24 09:50:30 2015
@@ -224,9 +224,14 @@
 	const struct ast_dns_record *record;
 	struct naptr_record records[] = {
 		{ 100, 100, "A", "BLAH", "", "goose.down" },
-		{ 100, 200, "A", "BLAH", "", "duck.down" },
+		{ 200, 200, "A", "BLAH", "", "duck.down" },
+		{ 100, 200, "A", "BLAH", "![^\\.]+\\.(.*)$!\\1!", "" },
+		{ 200, 100, "A", "BLAH", "!([^\\.]+\\.)(.*)$!\\1.happy.\\2!", "" },
 	};
+
+	int naptr_record_order[] = { 0, 2, 3, 1 };
 	enum ast_test_result_state res = AST_TEST_PASS;
+	int i;
 
 	switch (cmd) {
 	case TEST_INIT:
@@ -240,7 +245,7 @@
 	}
 
 	test_records = records;
-	num_test_records = 2;
+	num_test_records = ARRAY_LEN(records);
 	memset(ans_buffer, 0, sizeof(ans_buffer));
 
 	ast_dns_resolver_register(&naptr_resolver);
@@ -257,14 +262,38 @@
 		goto cleanup;
 	}
 
+	i = 0;
 	for (record = ast_dns_result_get_records(result); record; record = ast_dns_record_get_next(record)) {
-		ast_log(LOG_NOTICE, "Examining record\n");
-		ast_log(LOG_NOTICE, "order is %hu\n", ast_dns_naptr_get_order(record));
-		ast_log(LOG_NOTICE, "preference is %hu\n", ast_dns_naptr_get_preference(record));
-		ast_log(LOG_NOTICE, "flags is %s\n", ast_dns_naptr_get_flags(record));
-		ast_log(LOG_NOTICE, "service is %s\n", ast_dns_naptr_get_service(record));
-		ast_log(LOG_NOTICE, "regexp is %s\n", ast_dns_naptr_get_regexp(record));
-		ast_log(LOG_NOTICE, "replacement is %s\n", ast_dns_naptr_get_replacement(record));
+		if (ast_dns_naptr_get_order(record) != records[naptr_record_order[i]].order) {
+			ast_test_status_update(test, "Unexpected order in returned NAPTR record\n");
+			res = AST_TEST_FAIL;
+		}
+		if (ast_dns_naptr_get_preference(record) != records[naptr_record_order[i]].preference) {
+			ast_test_status_update(test, "Unexpected preference in returned NAPTR record\n");
+			res = AST_TEST_FAIL;
+		}
+		if (strcmp(ast_dns_naptr_get_flags(record), records[naptr_record_order[i]].flags)) {
+			ast_test_status_update(test, "Unexpected flags in returned NAPTR record\n");
+			res = AST_TEST_FAIL;
+		}
+		if (strcmp(ast_dns_naptr_get_service(record), records[naptr_record_order[i]].services)) {
+			ast_test_status_update(test, "Unexpected services in returned NAPTR record\n");
+			res = AST_TEST_FAIL;
+		}
+		if (strcmp(ast_dns_naptr_get_regexp(record), records[naptr_record_order[i]].regexp)) {
+			ast_test_status_update(test, "Unexpected regexp in returned NAPTR record\n");
+			res = AST_TEST_FAIL;
+		}
+		if (strcmp(ast_dns_naptr_get_replacement(record), records[naptr_record_order[i]].replacement)) {
+			ast_test_status_update(test, "Unexpected replacement in returned NAPTR record\n");
+			res = AST_TEST_FAIL;
+		}
+		++i;
+	}
+
+	if (i != ARRAY_LEN(records)) {
+		ast_test_status_update(test, "Unexpected number of records returned in NAPTR lookup\n");
+		res = AST_TEST_FAIL;
 	}
 
 cleanup:




More information about the svn-commits mailing list