]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add debug printfs
authorMark Andrews <marka@isc.org>
Thu, 28 Feb 2019 07:04:02 +0000 (18:04 +1100)
committerMark Andrews <marka@isc.org>
Thu, 11 Apr 2019 09:52:38 +0000 (19:52 +1000)
(cherry picked from commit b78e128a2ff26950bb9ff186b0614279e6f450c2)

lib/dns/tests/rdata_test.c

index d5d65604d347c26303270ec08039cf5da92b5439..de3bc89782a7bbca25fbbd6cda7bf81c2da788ae 100644 (file)
@@ -38,6 +38,8 @@
 
 #include "dnstest.h"
 
+static bool debug = false;
+
 /*
  * An array of these structures is passed to compare_ok().
  */
@@ -223,8 +225,14 @@ check_text_ok_single(const text_ok_t *text_ok, dns_rdataclass_t rdclass,
         * Check whether result is as expected.
         */
        if (text_ok->text_out != NULL) {
+               if (debug && result != ISC_R_SUCCESS) {
+                       fprintf(stdout, "#'%s'\n", text_ok->text_in);
+               }
                assert_int_equal(result, ISC_R_SUCCESS);
        } else {
+               if (debug && result == ISC_R_SUCCESS) {
+                       fprintf(stdout, "#'%s'\n", text_ok->text_in);
+               }
                assert_int_not_equal(result, ISC_R_SUCCESS);
        }
 
@@ -249,6 +257,10 @@ check_text_ok_single(const text_ok_t *text_ok, dns_rdataclass_t rdclass,
         * unused part of the buffer.
         */
        isc_buffer_putuint8(&target, 0);
+       if (debug && strcmp(buf_totext, text_ok->text_out) != 0) {
+               fprintf(stdout, "# '%s' != '%s'\n",
+                       buf_totext, text_ok->text_out);
+       }
        assert_string_equal(buf_totext, text_ok->text_out);
 
        /*
@@ -298,6 +310,9 @@ check_text_conversions(dns_rdata_t *rdata) {
         * unused part of the buffer.
         */
        isc_buffer_putuint8(&target, 0);
+       if (debug) {
+               fprintf(stdout, "#'%s'\n", buf_totext);
+       }
 
        /*
         * Try parsing text form RDATA output by dns_rdata_totext() again.
@@ -344,6 +359,9 @@ check_multiline_text_conversions(dns_rdata_t *rdata) {
         * writing into the apparently unused part of the buffer.
         */
        isc_buffer_putuint8(&target, 0);
+       if (debug) {
+               fprintf(stdout, "#'%s'\n", buf_totext);
+       }
 
        /*
         * Try parsing multi-line text form RDATA output by
@@ -2374,7 +2392,7 @@ iszonecutauth(void **state) {
 }
 
 int
-main(void) {
+main(int argc, char **argv) {
        const struct CMUnitTest tests[] = {
                cmocka_unit_test_setup_teardown(amtrelay, _setup, _teardown),
                cmocka_unit_test_setup_teardown(apl, _setup, _teardown),
@@ -2402,6 +2420,12 @@ main(void) {
                cmocka_unit_test_setup_teardown(iszonecutauth, NULL, NULL),
        };
 
+       UNUSED(argv);
+
+       if (argc > 1) {
+               debug = true;
+       }
+
        return (cmocka_run_group_tests(tests, dns_test_init, dns_test_final));
 }