]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
add unit tests for dns_rdatatype_atcname, dns_rdatatype_atparent and iszonecutauth
authorMark Andrews <marka@isc.org>
Wed, 12 Dec 2018 07:43:31 +0000 (18:43 +1100)
committerMark Andrews <marka@isc.org>
Fri, 14 Dec 2018 02:21:35 +0000 (13:21 +1100)
lib/dns/tests/rdata_test.c

index 46c30a4ad584ed4153feb6a11142e41756e9f3d4..0c4906c3cd5fd257c185455491c9014b70d1d62b 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <isc/hex.h>
 #include <isc/lex.h>
+#include <isc/print.h>
 #include <isc/stdio.h>
 #include <isc/types.h>
 #include <isc/util.h>
@@ -1499,6 +1500,90 @@ wks(void **state) {
                    dns_rdatatype_wks, sizeof(dns_rdata_in_wks_t));
 }
 
+static void
+atcname(void **state) {
+       unsigned int i;
+       UNUSED(state);
+#define UNR "# Unexpected result from dns_rdatatype_atcname for type %u\n"
+       for (i = 0; i < 0xffffU; i++) {
+               bool tf = dns_rdatatype_atcname((dns_rdatatype_t)i);
+               switch (i) {
+               case dns_rdatatype_nsec:
+               case dns_rdatatype_key:
+               case dns_rdatatype_rrsig:
+                       if (!tf) {
+                               print_message(UNR, i);
+                       }
+                       assert_true(tf);
+                       break;
+               default:
+                       if (tf) {
+                               print_message(UNR, i);
+                       }
+                       assert_false(tf);
+                       break;
+               }
+
+       }
+#undef UNR
+}
+
+static void
+atparent(void **state) {
+       unsigned int i;
+       UNUSED(state);
+#define UNR "# Unexpected result from dns_rdatatype_atparent for type %u\n"
+       for (i = 0; i < 0xffffU; i++) {
+               bool tf = dns_rdatatype_atparent((dns_rdatatype_t)i);
+               switch (i) {
+               case dns_rdatatype_ds:
+                       if (!tf) {
+                               print_message(UNR, i);
+                       }
+                       assert_true(tf);
+                       break;
+               default:
+                       if (tf) {
+                               print_message(UNR, i);
+                       }
+                       assert_false(tf);
+                       break;
+               }
+
+       }
+#undef UNR
+}
+
+static void
+iszonecutauth(void **state) {
+       unsigned int i;
+       UNUSED(state);
+#define UNR "# Unexpected result from dns_rdatatype_iszonecutauth for type %u\n"
+       for (i = 0; i < 0xffffU; i++) {
+               bool tf = dns_rdatatype_iszonecutauth((dns_rdatatype_t)i);
+               switch (i) {
+               case dns_rdatatype_ns:
+               case dns_rdatatype_ds:
+               case dns_rdatatype_nsec:
+               case dns_rdatatype_key:
+               case dns_rdatatype_rrsig:
+                       if (!tf) {
+                               print_message(UNR, i);
+                       }
+                       assert_true(tf);
+                       break;
+               default:
+                       if (tf) {
+                               print_message(UNR, i);
+                       }
+                       assert_false(tf);
+                       break;
+               }
+
+       }
+#undef UNR
+}
+
 int
 main(void) {
        const struct CMUnitTest tests[] = {
@@ -1516,6 +1601,9 @@ main(void) {
                cmocka_unit_test_setup_teardown(nsec3, _setup, _teardown),
                cmocka_unit_test_setup_teardown(nxt, _setup, _teardown),
                cmocka_unit_test_setup_teardown(wks, _setup, _teardown),
+               cmocka_unit_test_setup_teardown(atcname, NULL, NULL),
+               cmocka_unit_test_setup_teardown(atparent, NULL, NULL),
+               cmocka_unit_test_setup_teardown(iszonecutauth, NULL, NULL),
        };
 
        return (cmocka_run_group_tests(tests, NULL, NULL));