[Asterisk-code-review] tests dns: Make DNS tests older nameser.h compatible (asterisk[master])

snuffy asteriskteam at digium.com
Wed Dec 7 14:26:10 CST 2016


snuffy has uploaded a new change for review. ( https://gerrit.asterisk.org/4574 )

Change subject: tests_dns: Make DNS tests older nameser.h compatible
......................................................................

tests_dns: Make DNS tests older nameser.h compatible

Fix the tests for DNS to use older style nameser.h as
in ASTERISK-26608.

Tested on: OpenBSD 6.0, Debian 8

ASTERISK-26647 #close

Change-Id: I285913c44202537c04b3ed09c015efa6e5f9052d
---
M tests/test_dns.c
M tests/test_dns_naptr.c
M tests/test_dns_query_set.c
M tests/test_dns_recurring.c
M tests/test_dns_srv.c
5 files changed, 64 insertions(+), 64 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/74/4574/1

diff --git a/tests/test_dns.c b/tests/test_dns.c
index fbc329b..4c45c84 100644
--- a/tests/test_dns.c
+++ b/tests/test_dns.c
@@ -304,10 +304,10 @@
 		unsigned int bogus;
 		unsigned int rcode;
 	} results[] = {
-		{ 0, 0, ns_r_noerror, },
-		{ 0, 1, ns_r_noerror, },
-		{ 1, 0, ns_r_noerror, },
-		{ 0, 0, ns_r_nxdomain, },
+		{ 0, 0, NOERROR, },
+		{ 0, 1, NOERROR, },
+		{ 1, 0, NOERROR, },
+		{ 0, 0, NXDOMAIN, },
 	};
 	int i;
 	enum ast_test_result_state res = AST_TEST_PASS;
@@ -373,7 +373,7 @@
 
 	memset(&some_query, 0, sizeof(some_query));
 
-	if (!ast_dns_resolver_set_result(&some_query, 1, 1, ns_r_noerror, "asterisk.org",
+	if (!ast_dns_resolver_set_result(&some_query, 1, 1, NOERROR, "asterisk.org",
 				DNS_ANSWER, DNS_ANSWER_SIZE)) {
 		ast_test_status_update(test, "Successfully added a result that was both secure and bogus\n");
 		result = ast_dns_query_get_result(&some_query);
@@ -381,7 +381,7 @@
 		return AST_TEST_FAIL;
 	}
 
-	if (!ast_dns_resolver_set_result(&some_query, 0, 0, ns_r_noerror, NULL,
+	if (!ast_dns_resolver_set_result(&some_query, 0, 0, NOERROR, NULL,
 				DNS_ANSWER, DNS_ANSWER_SIZE)) {
 		ast_test_status_update(test, "Successfully added result with no canonical name\n");
 		result = ast_dns_query_get_result(&some_query);
@@ -440,8 +440,8 @@
 		const size_t size;
 		int visited;
 	} records[] = {
-		{ ns_t_a, ns_c_in, 12345, v4_buf, V4_BUFSIZE, 0, },
-		{ ns_t_aaaa, ns_c_in, 12345, v6_buf, V6_BUFSIZE, 0, },
+		{ T_A, C_IN, 12345, v4_buf, V4_BUFSIZE, 0, },
+		{ T_AAAA, C_IN, 12345, v6_buf, V6_BUFSIZE, 0, },
 	};
 
 	int num_records_visited = 0;
@@ -464,7 +464,7 @@
 
 	memset(&some_query, 0, sizeof(some_query));
 
-	if (ast_dns_resolver_set_result(&some_query, 0, 0, ns_r_noerror, "asterisk.org",
+	if (ast_dns_resolver_set_result(&some_query, 0, 0, NOERROR, "asterisk.org",
 				DNS_ANSWER, DNS_ANSWER_SIZE)) {
 		ast_test_status_update(test, "Unable to set result for DNS query\n");
 		return AST_TEST_FAIL;
@@ -578,12 +578,12 @@
 	inet_ntop(AF_INET, V4, v4_buf, V4_BUFSIZE);
 
 	/* Add record before setting result */
-	if (!ast_dns_resolver_add_record(&some_query, ns_t_a, ns_c_in, 12345, v4_buf, V4_BUFSIZE)) {
+	if (!ast_dns_resolver_add_record(&some_query, T_A, C_IN, 12345, v4_buf, V4_BUFSIZE)) {
 		ast_test_status_update(test, "Successfully added DNS record to query before setting a result\n");
 		return AST_TEST_FAIL;
 	}
 
-	if (ast_dns_resolver_set_result(&some_query, 0, 0, ns_r_noerror, "asterisk.org",
+	if (ast_dns_resolver_set_result(&some_query, 0, 0, NOERROR, "asterisk.org",
 				DNS_ANSWER, DNS_ANSWER_SIZE)) {
 		ast_test_status_update(test, "Unable to set result for DNS query\n");
 		return AST_TEST_FAIL;
@@ -593,41 +593,41 @@
 	result = ast_dns_query_get_result(&some_query);
 
 	/* Invalid RR types */
-	if (!ast_dns_resolver_add_record(&some_query, -1, ns_c_in, 12345, v4_buf, V4_BUFSIZE)) {
+	if (!ast_dns_resolver_add_record(&some_query, -1, C_IN, 12345, v4_buf, V4_BUFSIZE)) {
 		ast_test_status_update(test, "Successfully added DNS record with negative RR type\n");
 		return AST_TEST_FAIL;
 	}
 
-	if (!ast_dns_resolver_add_record(&some_query, ns_t_max + 1, ns_c_in, 12345, v4_buf, V4_BUFSIZE)) {
+	if (!ast_dns_resolver_add_record(&some_query, 65536 + 1, C_IN, 12345, v4_buf, V4_BUFSIZE)) {
 		ast_test_status_update(test, "Successfully added DNS record with too large RR type\n");
 		return AST_TEST_FAIL;
 	}
 
 	/* Invalid RR classes */
-	if (!ast_dns_resolver_add_record(&some_query, ns_t_a, -1, 12345, v4_buf, V4_BUFSIZE)) {
+	if (!ast_dns_resolver_add_record(&some_query, T_A, -1, 12345, v4_buf, V4_BUFSIZE)) {
 		ast_test_status_update(test, "Successfully added DNS record with negative RR class\n");
 		return AST_TEST_FAIL;
 	}
 
-	if (!ast_dns_resolver_add_record(&some_query, ns_t_a, ns_c_max + 1, 12345, v4_buf, V4_BUFSIZE)) {
+	if (!ast_dns_resolver_add_record(&some_query, T_A, 65536 + 1, 12345, v4_buf, V4_BUFSIZE)) {
 		ast_test_status_update(test, "Successfully added DNS record with too large RR class\n");
 		return AST_TEST_FAIL;
 	}
 
 	/* Invalid TTL */
-	if (!ast_dns_resolver_add_record(&some_query, ns_t_a, ns_c_in, -1, v4_buf, V4_BUFSIZE)) {
+	if (!ast_dns_resolver_add_record(&some_query, T_A, C_IN, -1, v4_buf, V4_BUFSIZE)) {
 		ast_test_status_update(test, "Successfully added DNS record with negative TTL\n");
 		return AST_TEST_FAIL;
 	}
 
 	/* No data */
-	if (!ast_dns_resolver_add_record(&some_query, ns_t_a, ns_c_in, 12345, NULL, 0)) {
+	if (!ast_dns_resolver_add_record(&some_query, T_A, C_IN, 12345, NULL, 0)) {
 		ast_test_status_update(test, "Successfully added a DNS record with no data\n");
 		return AST_TEST_FAIL;
 	}
 
 	/* Lie about the length */
-	if (!ast_dns_resolver_add_record(&some_query, ns_t_a, ns_c_in, 12345, v4_buf, 0)) {
+	if (!ast_dns_resolver_add_record(&some_query, T_A, C_IN, 12345, v4_buf, 0)) {
 		ast_test_status_update(test, "Successfully added a DNS record with length zero\n");
 		return AST_TEST_FAIL;
 	}
@@ -693,10 +693,10 @@
 		return NULL;
 	}
 
-	ast_dns_resolver_set_result(query, 0, 0, ns_r_noerror, "asterisk.org", DNS_ANSWER, DNS_ANSWER_SIZE);
+	ast_dns_resolver_set_result(query, 0, 0, NOERROR, "asterisk.org", DNS_ANSWER, DNS_ANSWER_SIZE);
 
 	inet_pton(AF_INET, V4, v4_buf);
-	ast_dns_resolver_add_record(query, ns_t_a, ns_c_in, 12345, v4_buf, V4_BUFSIZE);
+	ast_dns_resolver_add_record(query, T_A, C_IN, 12345, v4_buf, V4_BUFSIZE);
 
 	test_resolver_data.resolution_complete = 1;
 	ast_dns_resolver_completed(query);
@@ -806,7 +806,7 @@
 
 	resolver_data_init();
 
-	if (ast_dns_resolve("asterisk.org", ns_t_a, ns_c_in, &result)) {
+	if (ast_dns_resolve("asterisk.org", T_A, C_IN, &result)) {
 		ast_test_status_update(test, "Resolution of address failed\n");
 		res = AST_TEST_FAIL;
 		goto cleanup;
@@ -876,12 +876,12 @@
 		int rr_class;
 		struct ast_dns_result **result;
 	} resolves [] = {
-		{ NULL,           ns_t_a,       ns_c_in,      &result },
-		{ "asterisk.org", -1,           ns_c_in,      &result },
-		{ "asterisk.org", ns_t_max + 1, ns_c_in,      &result },
-		{ "asterisk.org", ns_t_a,       -1,           &result },
-		{ "asterisk.org", ns_t_a,       ns_c_max + 1, &result },
-		{ "asterisk.org", ns_t_a,       ns_c_in,      NULL },
+		{ NULL,           T_A,       C_IN,      &result },
+		{ "asterisk.org", -1,        C_IN,      &result },
+		{ "asterisk.org", 65536 + 1, C_IN,      &result },
+		{ "asterisk.org", T_A,       -1,        &result },
+		{ "asterisk.org", T_A,       65536 + 1, &result },
+		{ "asterisk.org", T_A,       C_IN,      NULL },
 	};
 
 	int i;
@@ -929,7 +929,7 @@
 		return AST_TEST_FAIL;
 	}
 
-	if (!ast_dns_resolve("asterisk.org", ns_t_a, ns_c_in, &result)) {
+	if (!ast_dns_resolve("asterisk.org", T_A, C_IN, &result)) {
 		ast_test_status_update(test, "DNS resolution succeeded when we expected it not to\n");
 		ast_dns_resolver_unregister(&terrible_resolver);
 		return AST_TEST_FAIL;
@@ -1052,7 +1052,7 @@
 		goto cleanup;
 	}
 
-	active = ast_dns_resolve_async("asterisk.org", ns_t_a, ns_c_in, async_callback, async_data);
+	active = ast_dns_resolve_async("asterisk.org", T_A, C_IN, async_callback, async_data);
 	if (!active) {
 		ast_test_status_update(test, "Asynchronous resolution of address failed\n");
 		res = AST_TEST_FAIL;
@@ -1133,12 +1133,12 @@
 		int rr_class;
 		ast_dns_resolve_callback callback;
 	} resolves [] = {
-		{ NULL,           ns_t_a,       ns_c_in,      stub_callback },
-		{ "asterisk.org", -1,           ns_c_in,      stub_callback },
-		{ "asterisk.org", ns_t_max + 1, ns_c_in,      stub_callback },
-		{ "asterisk.org", ns_t_a,       -1,           stub_callback },
-		{ "asterisk.org", ns_t_a,       ns_c_max + 1, stub_callback },
-		{ "asterisk.org", ns_t_a,       ns_c_in,      NULL },
+		{ NULL,           T_A,       C_IN,      stub_callback },
+		{ "asterisk.org", -1,        C_IN,      stub_callback },
+		{ "asterisk.org", 65536 + 1, C_IN,      stub_callback },
+		{ "asterisk.org", T_A,       -1,        stub_callback },
+		{ "asterisk.org", T_A,       65536 + 1, stub_callback },
+		{ "asterisk.org", T_A,       C_IN,      NULL },
 	};
 
 	struct ast_dns_query_active *active;
@@ -1184,7 +1184,7 @@
 		return AST_TEST_FAIL;
 	}
 
-	active = ast_dns_resolve_async("asterisk.org", ns_t_a, ns_c_in, stub_callback, NULL);
+	active = ast_dns_resolve_async("asterisk.org", T_A, C_IN, stub_callback, NULL);
 
 	ast_dns_resolver_unregister(&terrible_resolver);
 
@@ -1234,7 +1234,7 @@
 		goto cleanup;
 	}
 
-	active = ast_dns_resolve_async("asterisk.org", ns_t_a, ns_c_in, async_callback, async_data);
+	active = ast_dns_resolve_async("asterisk.org", T_A, C_IN, async_callback, async_data);
 	if (!active) {
 		ast_test_status_update(test, "Asynchronous resolution of address failed\n");
 		res = AST_TEST_FAIL;
diff --git a/tests/test_dns_naptr.c b/tests/test_dns_naptr.c
index 96c745d..dc9e908 100644
--- a/tests/test_dns_naptr.c
+++ b/tests/test_dns_naptr.c
@@ -116,14 +116,14 @@
 	ans_size = ast_dns_test_generate_result(query, test_records, num_test_records,
 			sizeof(struct naptr_record), generate_naptr_record, ans_buffer);
 
-	ast_dns_resolver_set_result(query, 0, 0, ns_r_noerror, "goose.feathers", ans_buffer, ans_size);
+	ast_dns_resolver_set_result(query, 0, 0, NOERROR, "goose.feathers", ans_buffer, ans_size);
 
 	for (i = 0; i < num_test_records; ++i) {
 		char record[128];
 		int naptr_size;
 
 		naptr_size = generate_naptr_record(&test_records[i], record);
-		ast_dns_resolver_add_record(query, ns_t_naptr, ns_c_in, 12345, record, naptr_size);
+		ast_dns_resolver_add_record(query, T_NAPTR, C_IN, 12345, record, naptr_size);
 	}
 
 	ast_dns_resolver_completed(query);
@@ -209,7 +209,7 @@
 
 	ast_dns_resolver_register(&naptr_resolver);
 
-	if (ast_dns_resolve("goose.feathers", ns_t_naptr, ns_c_in, &result)) {
+	if (ast_dns_resolve("goose.feathers", T_NAPTR, C_IN, &result)) {
 		ast_test_status_update(test, "DNS resolution failed\n");
 		res = AST_TEST_FAIL;
 		goto cleanup;
@@ -284,7 +284,7 @@
 
 	ast_dns_resolver_register(&naptr_resolver);
 
-	if (ast_dns_resolve("goose.feathers", ns_t_naptr, ns_c_in, &result)) {
+	if (ast_dns_resolve("goose.feathers", T_NAPTR, C_IN, &result)) {
 		ast_test_status_update(test, "Failed to perform DNS resolution, despite using valid inputs\n");
 		res = AST_TEST_FAIL;
 		goto cleanup;
diff --git a/tests/test_dns_query_set.c b/tests/test_dns_query_set.c
index aeb61c7..d1e9683 100644
--- a/tests/test_dns_query_set.c
+++ b/tests/test_dns_query_set.c
@@ -94,7 +94,7 @@
 
 	ast_assert(qsdata != NULL);
 
-	ast_dns_resolver_set_result(query, 0, 0, ns_r_noerror, "asterisk.org", DNS_ANSWER, DNS_ANSWER_SIZE);
+	ast_dns_resolver_set_result(query, 0, 0, NOERROR, "asterisk.org", DNS_ANSWER, DNS_ANSWER_SIZE);
 	ast_dns_resolver_completed(query);
 
 	ao2_ref(query, -1);
@@ -210,7 +210,7 @@
 	qsdata->cancel_allowed = cancel;
 
 	for (idx = 0; idx < total; ++idx) {
-		if (ast_dns_query_set_add(query_set, "asterisk.org", ns_t_a, ns_c_in)) {
+		if (ast_dns_query_set_add(query_set, "asterisk.org", T_A, C_IN)) {
 			ast_test_status_update(test, "Failed to add query to DNS query set\n");
 			res = AST_TEST_FAIL;
 			goto cleanup;
@@ -269,11 +269,11 @@
 			ast_test_status_update(test, "Query did not have expected name\n");
 			res = AST_TEST_FAIL;
 		}
-		if (ast_dns_query_get_rr_type(query) != ns_t_a) {
+		if (ast_dns_query_get_rr_type(query) != T_A) {
 			ast_test_status_update(test, "Query did not have expected type\n");
 			res = AST_TEST_FAIL;
 		}
-		if (ast_dns_query_get_rr_class(query) != ns_c_in) {
+		if (ast_dns_query_get_rr_class(query) != C_IN) {
 			ast_test_status_update(test, "Query did not have expected class\n");
 			res = AST_TEST_FAIL;
 		}
diff --git a/tests/test_dns_recurring.c b/tests/test_dns_recurring.c
index d1add6e..2596e43 100644
--- a/tests/test_dns_recurring.c
+++ b/tests/test_dns_recurring.c
@@ -129,13 +129,13 @@
 	/* When the query isn't canceled, we set the TTL of the results based on what
 	 * we've been told to set it to
 	 */
-	ast_dns_resolver_set_result(query, 0, 0, ns_r_noerror, "asterisk.org", DNS_ANSWER, DNS_ANSWER_SIZE);
+	ast_dns_resolver_set_result(query, 0, 0, NOERROR, "asterisk.org", DNS_ANSWER, DNS_ANSWER_SIZE);
 
 	inet_pton(AF_INET, ADDR1, addr1_buf);
-	ast_dns_resolver_add_record(query, ns_t_a, ns_c_in, rdata->ttl1, addr1_buf, ADDR1_BUFSIZE);
+	ast_dns_resolver_add_record(query, T_A, C_IN, rdata->ttl1, addr1_buf, ADDR1_BUFSIZE);
 
 	inet_pton(AF_INET, ADDR2, addr2_buf);
-	ast_dns_resolver_add_record(query, ns_t_a, ns_c_in, rdata->ttl2, addr2_buf, ADDR2_BUFSIZE);
+	ast_dns_resolver_add_record(query, T_A, C_IN, rdata->ttl2, addr2_buf, ADDR2_BUFSIZE);
 
 	++rdata->complete_resolutions;
 
@@ -308,7 +308,7 @@
 	rdata->ttl1 = 5;
 	rdata->ttl2 = 20;
 
-	recurring_query = ast_dns_resolve_recurring("asterisk.org", ns_t_a, ns_c_in, async_callback, rdata);
+	recurring_query = ast_dns_resolve_recurring("asterisk.org", T_A, C_IN, async_callback, rdata);
 	if (!recurring_query) {
 		ast_test_status_update(test, "Failed to create recurring DNS query\n");
 		res = AST_TEST_FAIL;
@@ -382,12 +382,12 @@
 		int rr_class;
 		ast_dns_resolve_callback callback;
 	} resolves [] = {
-		{ NULL,           ns_t_a,       ns_c_in,      stub_callback },
-		{ "asterisk.org", -1,           ns_c_in,      stub_callback },
-		{ "asterisk.org", ns_t_max + 1, ns_c_in,      stub_callback },
-		{ "asterisk.org", ns_t_a,       -1,           stub_callback },
-		{ "asterisk.org", ns_t_a,       ns_c_max + 1, stub_callback },
-		{ "asterisk.org", ns_t_a,       ns_c_in,      NULL },
+		{ NULL,           T_A,       C_IN,      stub_callback },
+		{ "asterisk.org", -1,        C_IN,      stub_callback },
+		{ "asterisk.org", 65536 + 1, C_IN,      stub_callback },
+		{ "asterisk.org", T_A,       -1,        stub_callback },
+		{ "asterisk.org", T_A,       65536 + 1, stub_callback },
+		{ "asterisk.org", T_A,       C_IN,      NULL },
 	};
 	int i;
 	enum ast_test_result_state res = AST_TEST_PASS;
@@ -432,7 +432,7 @@
 		return AST_TEST_FAIL;
 	}
 
-	recurring = ast_dns_resolve_recurring("asterisk.org", ns_t_a, ns_c_in, stub_callback, NULL);
+	recurring = ast_dns_resolve_recurring("asterisk.org", T_A, C_IN, stub_callback, NULL);
 
 	ast_dns_resolver_unregister(&terrible_resolver);
 
@@ -483,7 +483,7 @@
 	rdata->ttl1 = 5;
 	rdata->ttl2 = 20;
 
-	recurring_query = ast_dns_resolve_recurring("asterisk.org", ns_t_a, ns_c_in, async_callback, rdata);
+	recurring_query = ast_dns_resolve_recurring("asterisk.org", T_A, C_IN, async_callback, rdata);
 	if (!recurring_query) {
 		ast_test_status_update(test, "Unable to make recurring query\n");
 		res = AST_TEST_FAIL;
@@ -566,7 +566,7 @@
 	rdata->ttl1 = 5;
 	rdata->ttl2 = 20;
 
-	recurring_query = ast_dns_resolve_recurring("asterisk.org", ns_t_a, ns_c_in, async_callback, rdata);
+	recurring_query = ast_dns_resolve_recurring("asterisk.org", T_A, C_IN, async_callback, rdata);
 	if (!recurring_query) {
 		ast_test_status_update(test, "Failed to make recurring DNS query\n");
 		res = AST_TEST_FAIL;
diff --git a/tests/test_dns_srv.c b/tests/test_dns_srv.c
index 2e89dab..db71beb 100644
--- a/tests/test_dns_srv.c
+++ b/tests/test_dns_srv.c
@@ -87,14 +87,14 @@
 	ans_size = ast_dns_test_generate_result(query, test_records, num_test_records,
 			sizeof(struct srv_record), generate_srv_record, ans_buffer);
 
-	ast_dns_resolver_set_result(query, 0, 0, ns_r_noerror, "goose.feathers", ans_buffer, ans_size);
+	ast_dns_resolver_set_result(query, 0, 0, NOERROR, "goose.feathers", ans_buffer, ans_size);
 
 	for (i = 0; i < num_test_records; ++i) {
 		char record[128];
 		int srv_size;
 
 		srv_size = generate_srv_record(&test_records[i], record);
-		ast_dns_resolver_add_record(query, ns_t_srv, ns_c_in, 12345, record, srv_size);
+		ast_dns_resolver_add_record(query, T_SRV, C_IN, 12345, record, srv_size);
 	}
 
 	ast_dns_resolver_completed(query);
@@ -136,7 +136,7 @@
 
 	ast_dns_resolver_register(&srv_resolver);
 
-	if (ast_dns_resolve("goose.feathers", ns_t_srv, ns_c_in, &result)) {
+	if (ast_dns_resolve("goose.feathers", T_SRV, C_IN, &result)) {
 		ast_test_status_update(test, "DNS resolution failed\n");
 		res = AST_TEST_FAIL;
 		goto cleanup;
@@ -295,7 +295,7 @@
 
 		memset(ans_buffer, 0, sizeof(ans_buffer));
 
-		if (ast_dns_resolve("goose.feathers", ns_t_srv, ns_c_in, &result)) {
+		if (ast_dns_resolve("goose.feathers", T_SRV, C_IN, &result)) {
 			ast_test_status_update(test, "DNS resolution failed\n");
 			res = AST_TEST_FAIL;
 			goto cleanup;
@@ -385,7 +385,7 @@
 
 		memset(ans_buffer, 0, sizeof(ans_buffer));
 
-		if (ast_dns_resolve("goose.feathers", ns_t_srv, ns_c_in, &result)) {
+		if (ast_dns_resolve("goose.feathers", T_SRV, C_IN, &result)) {
 			ast_test_status_update(test, "DNS resolution failed\n");
 			res = AST_TEST_FAIL;
 			goto cleanup;
@@ -462,7 +462,7 @@
 
 	ast_dns_resolver_register(&srv_resolver);
 
-	if (ast_dns_resolve("goose.feathers", ns_t_srv, ns_c_in, &result)) {
+	if (ast_dns_resolve("goose.feathers", T_SRV, C_IN, &result)) {
 		ast_test_status_update(test, "DNS resolution failed\n");
 		res = AST_TEST_FAIL;
 		goto cleanup;

-- 
To view, visit https://gerrit.asterisk.org/4574
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I285913c44202537c04b3ed09c015efa6e5f9052d
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: snuffy <snuffy22 at gmail.com>



More information about the asterisk-code-review mailing list