]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
remove (or hide behind a 'verbose' flag) extra output from system tests
authorEvan Hunt <each@isc.org>
Fri, 16 Nov 2018 08:19:06 +0000 (08:19 +0000)
committerEvan Hunt <each@isc.org>
Fri, 16 Nov 2018 20:46:14 +0000 (20:46 +0000)
lib/dns/tests/keytable_test.c
lib/dns/tests/master_test.c
lib/dns/tests/name_test.c
lib/dns/tests/rbt_serialize_test.c
lib/dns/tests/tkey_test.c
lib/isc/tests/random_test.c
lib/isc/tests/regex_test.c
lib/isc/tests/task_test.c
lib/isc/tests/timer_test.c

index 43c0b8e35d2518dd64a139cd7223ad30b3130a3a..1a6c7100f2193de1218b72243f41c96655732843 100644 (file)
@@ -620,6 +620,8 @@ issecuredomain_test(void **state) {
 /* check dns_keytable_dump() */
 static void
 dump_test(void **state) {
+       FILE *f = fopen("/dev/null", "w");
+
        UNUSED(state);
 
        create_tables();
@@ -628,7 +630,8 @@ dump_test(void **state) {
         * Right now, we only confirm the dump attempt doesn't cause disruption
         * (so we don't check the dump content).
         */
-       assert_int_equal(dns_keytable_dump(keytable, stdout), ISC_R_SUCCESS);
+       assert_int_equal(dns_keytable_dump(keytable, f), ISC_R_SUCCESS);
+       fclose(f);
 
        destroy_tables();
 }
index 4557f8c2548f1381f99b68e83d56f6a32a91d0f9..859889f2bfdc00bcf60a63dacb7c8e619fba565f 100644 (file)
@@ -65,6 +65,15 @@ _teardown(void **state) {
        return (0);
 }
 
+static void
+nullmsg(dns_rdatacallbacks_t *cb, const char *fmt, ...) {
+       va_list ap;
+
+       UNUSED(cb);
+       UNUSED(fmt);
+       UNUSED(ap);
+}
+
 #define        BUFLEN          255
 #define        BIGBUFLEN       (70 * 1024)
 #define TEST_ORIGIN    "test"
@@ -152,6 +161,17 @@ test_master(const char *testfile, dns_masterformat_t format,
                return(result);
        }
 
+       dns_rdatacallbacks_init_stdio(&callbacks);
+       callbacks.add = add_callback;
+       callbacks.rawdata = rawdata_callback;
+       callbacks.zone = NULL;
+       if (warn != NULL) {
+               callbacks.warn = warn;
+       }
+       if (error != NULL) {
+               callbacks.error = error;
+       }
+
        result = dns_master_loadfile(testfile, &dns_origin, &dns_origin,
                                     dns_rdataclass_in, true, 0,
                                     &callbacks, NULL, NULL, mctx, format, 0);
@@ -175,7 +195,7 @@ load_test(void **state) {
        UNUSED(state);
 
        result = test_master("testdata/master/master1.data",
-                            dns_masterformat_text, NULL, NULL);
+                            dns_masterformat_text, nullmsg, nullmsg);
        assert_int_equal(result, ISC_R_SUCCESS);
 }
 
@@ -191,7 +211,7 @@ unexpected_test(void **state) {
        UNUSED(state);
 
        result = test_master("testdata/master/master2.data",
-                            dns_masterformat_text, NULL, NULL);
+                            dns_masterformat_text, nullmsg, nullmsg);
        assert_int_equal(result, ISC_R_UNEXPECTEDEND);
 }
 
@@ -207,7 +227,7 @@ noowner_test(void **state) {
        UNUSED(state);
 
        result = test_master("testdata/master/master3.data",
-                            dns_masterformat_text, NULL, NULL);
+                            dns_masterformat_text, nullmsg, nullmsg);
        assert_int_equal(result, DNS_R_NOOWNER);
 }
 
@@ -223,7 +243,7 @@ nottl_test(void **state) {
        UNUSED(state);
 
        result = test_master("testdata/master/master4.data",
-                            dns_masterformat_text, NULL, NULL);
+                            dns_masterformat_text, nullmsg, nullmsg);
        assert_int_equal(result, ISC_R_SUCCESS);
 }
 
@@ -239,7 +259,7 @@ badclass_test(void **state) {
        UNUSED(state);
 
        result = test_master("testdata/master/master5.data",
-                            dns_masterformat_text, NULL, NULL);
+                            dns_masterformat_text, nullmsg, nullmsg);
        assert_int_equal(result, DNS_R_BADCLASS);
 }
 
@@ -254,7 +274,7 @@ toobig_test(void **state) {
        UNUSED(state);
 
        result = test_master("testdata/master/master15.data",
-                            dns_masterformat_text, NULL, NULL);
+                            dns_masterformat_text, nullmsg, nullmsg);
        assert_int_equal(result, ISC_R_NOSPACE);
 }
 
@@ -269,7 +289,7 @@ maxrdata_test(void **state) {
        UNUSED(state);
 
        result = test_master("testdata/master/master16.data",
-                            dns_masterformat_text, NULL, NULL);
+                            dns_masterformat_text, nullmsg, nullmsg);
        assert_int_equal(result, ISC_R_SUCCESS);
 }
 
@@ -284,7 +304,7 @@ dnskey_test(void **state) {
        UNUSED(state);
 
        result = test_master("testdata/master/master6.data",
-                            dns_masterformat_text, NULL, NULL);
+                            dns_masterformat_text, nullmsg, nullmsg);
        assert_int_equal(result, ISC_R_SUCCESS);
 }
 
@@ -300,7 +320,7 @@ dnsnokey_test(void **state) {
        UNUSED(state);
 
        result = test_master("testdata/master/master7.data",
-                            dns_masterformat_text, NULL, NULL);
+                            dns_masterformat_text, nullmsg, nullmsg);
        assert_int_equal(result, ISC_R_SUCCESS);
 }
 
@@ -315,7 +335,7 @@ include_test(void **state) {
        UNUSED(state);
 
        result = test_master("testdata/master/master8.data",
-                            dns_masterformat_text, NULL, NULL);
+                            dns_masterformat_text, nullmsg, nullmsg);
        assert_int_equal(result, DNS_R_SEENINCLUDE);
 }
 
@@ -330,7 +350,7 @@ master_includelist_test(void **state) {
 
        UNUSED(state);
 
-       result = setup_master(NULL, NULL);
+       result = setup_master(nullmsg, nullmsg);
        assert_int_equal(result, ISC_R_SUCCESS);
 
        result = dns_master_loadfile("testdata/master/master8.data",
@@ -357,7 +377,7 @@ includefail_test(void **state) {
        UNUSED(state);
 
        result = test_master("testdata/master/master9.data",
-                            dns_masterformat_text, NULL, NULL);
+                            dns_masterformat_text, nullmsg, nullmsg);
        assert_int_equal(result, DNS_R_BADCLASS);
 }
 
@@ -372,7 +392,7 @@ blanklines_test(void **state) {
        UNUSED(state);
 
        result = test_master("testdata/master/master10.data",
-                            dns_masterformat_text, NULL, NULL);
+                            dns_masterformat_text, nullmsg, nullmsg);
        assert_int_equal(result, ISC_R_SUCCESS);
 }
 
@@ -388,7 +408,7 @@ leadingzero_test(void **state) {
        UNUSED(state);
 
        result = test_master("testdata/master/master11.data",
-                            dns_masterformat_text, NULL, NULL);
+                            dns_masterformat_text, nullmsg, nullmsg);
        assert_int_equal(result, ISC_R_SUCCESS);
 }
 
@@ -439,21 +459,21 @@ loadraw_test(void **state) {
 
        /* Raw format version 0 */
        result = test_master("testdata/master/master12.data",
-                            dns_masterformat_raw, NULL, NULL);
+                            dns_masterformat_raw, nullmsg, nullmsg);
        assert_string_equal(isc_result_totext(result), "success");
        assert_true(headerset);
        assert_int_equal(header.flags, 0);
 
        /* Raw format version 1, no source serial  */
        result = test_master("testdata/master/master13.data",
-                            dns_masterformat_raw, NULL, NULL);
+                            dns_masterformat_raw, nullmsg, nullmsg);
        assert_string_equal(isc_result_totext(result), "success");
        assert_true(headerset);
        assert_int_equal(header.flags, 0);
 
        /* Raw format version 1, source serial == 2011120101 */
        result = test_master("testdata/master/master14.data",
-                            dns_masterformat_raw, NULL, NULL);
+                            dns_masterformat_raw, nullmsg, nullmsg);
        assert_string_equal(isc_result_totext(result), "success");
        assert_true(headerset);
        assert_true((header.flags & DNS_MASTERRAW_SOURCESERIALSET) != 0);
@@ -503,7 +523,8 @@ dumpraw_test(void **state) {
                                 dns_masterformat_raw, NULL);
        assert_int_equal(result, ISC_R_SUCCESS);
 
-       result = test_master("test.dump", dns_masterformat_raw, NULL, NULL);
+       result = test_master("test.dump", dns_masterformat_raw,
+                            nullmsg, nullmsg);
        assert_string_equal(isc_result_totext(result), "success");
        assert_true(headerset);
        assert_int_equal(header.flags, 0);
@@ -518,7 +539,8 @@ dumpraw_test(void **state) {
                                 dns_masterformat_raw, &header);
        assert_int_equal(result, ISC_R_SUCCESS);
 
-       result = test_master("test.dump", dns_masterformat_raw, NULL, NULL);
+       result = test_master("test.dump", dns_masterformat_raw,
+                            nullmsg, nullmsg);
        assert_string_equal(isc_result_totext(result), "success");
        assert_true(headerset);
        assert_true((header.flags & DNS_MASTERRAW_SOURCESERIALSET) != 0);
@@ -564,7 +586,7 @@ neworigin_test(void **state) {
 
        warn_expect_value = "record with inherited owner";
        result = test_master("testdata/master/master17.data",
-                            dns_masterformat_text, warn_expect, NULL);
+                            dns_masterformat_text, warn_expect, nullmsg);
        assert_int_equal(result, ISC_R_SUCCESS);
        assert_true(warn_expect_result);
 }
index 20fcec8b0eeb7c77be1bb9fb242fee651dd6770f..4974eea81d741633bfb497376a20041abc9ecc6b 100644 (file)
@@ -40,6 +40,9 @@
 
 #include "dnstest.h"
 
+/* Set to true (or use -v option) for verbose output */
+static bool verbose = false;
+
 static int
 _setup(void **state) {
        isc_result_t result;
@@ -470,8 +473,12 @@ hash_test(void **state) {
                h1 = dns_name_hash(n1, false);
                h2 = dns_name_hash(n2, false);
 
-               printf("%s hashes to %u, %s to %u, case insensitive\n",
-                      testcases[i].name1, h1, testcases[i].name2, h2);
+               if (verbose) {
+                       print_message("# %s hashes to %u, "
+                                     "%s to %u, case insensitive\n",
+                                     testcases[i].name1, h1,
+                                     testcases[i].name2, h2);
+               }
 
                assert_int_equal((h1 == h2), testcases[i].expect);
 
@@ -479,8 +486,12 @@ hash_test(void **state) {
                h1 = dns_name_hash(n1, false);
                h2 = dns_name_hash(n2, false);
 
-               printf("%s hashes to %u, %s to %u, case sensitive\n",
-                      testcases[i].name1, h1, testcases[i].name2, h2);
+               if (verbose) {
+                       print_message("# %s hashes to %u, "
+                                     "%s to %u, case sensitive\n",
+                                     testcases[i].name1, h1,
+                                     testcases[i].name2, h2);
+               }
 
                assert_int_equal((h1 == h2), testcases[i].expect);
        }
@@ -521,10 +532,12 @@ issubdomain_test(void **state) {
                                              NULL, 0, NULL);
                assert_int_equal(result, ISC_R_SUCCESS);
 
-               printf("check: %s %s a subdomain of %s\n",
-                      testcases[i].name1,
-                      testcases[i].expect ? "is" : "is not",
-                      testcases[i].name2);
+               if (verbose) {
+                       print_message("# check: %s %s a subdomain of %s\n",
+                                     testcases[i].name1,
+                                     testcases[i].expect ? "is" : "is not",
+                                     testcases[i].name2);
+               }
 
                assert_int_equal(dns_name_issubdomain(n1, n2),
                             testcases[i].expect);
@@ -560,8 +573,11 @@ countlabels_test(void **state) {
                                              NULL, 0, NULL);
                assert_int_equal(result, ISC_R_SUCCESS);
 
-               printf("%s: expect %u labels\n",
-                      testcases[i].namestr, testcases[i].expect);
+               if (verbose) {
+                       print_message("# %s: expect %u labels\n",
+                                     testcases[i].namestr,
+                                     testcases[i].expect);
+               }
 
                assert_int_equal(dns_name_countlabels(name),
                               testcases[i].expect);
@@ -753,7 +769,7 @@ benchmark_test(void **state) {
 #endif /* DNS_BENCHMARK_TESTS */
 
 int
-main(void) {
+main(int argc, char **argv) {
        const struct CMUnitTest tests[] = {
                cmocka_unit_test(fullcompare_test),
                cmocka_unit_test_setup_teardown(compression_test,
@@ -773,6 +789,18 @@ main(void) {
                                                _setup, _teardown),
 #endif /* DNS_BENCHMARK_TESTS */
        };
+       int c;
+
+       while ((c = isc_commandline_parse(argc, argv, "v")) != -1) {
+               switch (c) {
+               case 'v':
+                       verbose = true;
+                       break;
+               default:
+                       break;
+               }
+       }
+
 
        return (cmocka_run_group_tests(tests, NULL, NULL));
 }
index 35624a2093a101db75fd3f8e26bedaafa385c5db..932cb5edb52b6f7e11283850bb97935dd6992c5d 100644 (file)
 #define UNIT_TESTING
 #include <cmocka.h>
 
-#include <isc/mem.h>
-#include <isc/print.h>
-#include <isc/random.h>
-#include <isc/string.h>
-
 #include <dns/rbt.h>
 #include <dns/fixedname.h>
 #include <dns/result.h>
 
 #include <isc/app.h>
 #include <isc/buffer.h>
+#include <isc/commandline.h>
 #include <isc/file.h>
 #include <isc/hash.h>
 #include <isc/mem.h>
 #include <isc/os.h>
+#include <isc/print.h>
+#include <isc/random.h>
 #include <isc/string.h>
 #include <isc/socket.h>
 #include <isc/stdio.h>
@@ -61,6 +59,9 @@
 #define MAP_FILE 0
 #endif
 
+/* Set to true (or use -v option) for verbose output */
+static bool verbose = false;
+
 static int
 _setup(void **state) {
        isc_result_t result;
@@ -314,7 +315,9 @@ serialize_test(void **state) {
 
        add_test_data(mctx, rbt);
 
-       dns_rbt_printtext(rbt, data_printer, stdout);
+       if (verbose) {
+               dns_rbt_printtext(rbt, data_printer, stdout);
+       }
 
        /*
         * Serialize the tree.
@@ -349,7 +352,9 @@ serialize_test(void **state) {
 
        check_test_data(rbt_deserialized);
 
-       dns_rbt_printtext(rbt_deserialized, data_printer, stdout);
+       if (verbose) {
+               dns_rbt_printtext(rbt_deserialized, data_printer, stdout);
+       }
 
        dns_rbt_destroy(&rbt_deserialized);
        munmap(base, filesize);
@@ -445,7 +450,7 @@ serialize_align_test(void **state) {
 }
 
 int
-main(void) {
+main(int argc, char **argv) {
        const struct CMUnitTest tests[] = {
                cmocka_unit_test_setup_teardown(serialize_test,
                                                _setup, _teardown),
@@ -453,6 +458,17 @@ main(void) {
                                                _setup, _teardown),
                cmocka_unit_test(serialize_align_test),
        };
+       int c;
+
+       while ((c = isc_commandline_parse(argc, argv, "v")) != -1) {
+               switch (c) {
+               case 'v':
+                       verbose = true;
+                       break;
+               default:
+                       break;
+               }
+       }
 
        return (cmocka_run_group_tests(tests, NULL, NULL));
 }
index 844a35289a4c7fb1e1dcaa54e6c6fe830d167791..629ed81dcb96688ed6928d2fc0248119ec4579d3 100644 (file)
@@ -123,7 +123,7 @@ main(void) {
        };
        return (cmocka_run_group_tests(tkey_tests, NULL, NULL));
 #else
-       print_message("1..0 # Skip tkey_test requires LD_WRAP");
+       print_message("1..0 # Skip tkey_test requires LD_WRAP\n");
 #endif /* LD_WRAP */
 }
 
index 74b3ed9dbe3a4046721ba8da414926938726ab8d..f60422fb5720adfa73f09da4ce518f700a71a783 100644 (file)
@@ -63,6 +63,7 @@ static double biginv =        2.22044604925031308085e-16;
 static double igamc(double a, double x);
 static double igam(double a, double x);
 
+/* Set to true (or use -v option) for verbose output */
 static bool verbose = false;
 
 typedef enum {
index 6cb799e4c9a37f7836ed6c585ec70fe46c794876..86e9439caf0a101e2f7801e688cc83790869d8b9 100644 (file)
@@ -34,7 +34,7 @@
 #include <isc/print.h>
 #include <isc/util.h>
 
-/* Set to true for verbose output */
+/* Set to true (or use -v option) for verbose output */
 static bool verbose = false;
 
 /* test isc_regex_validate() */
index 1b50c923afa9d975b136af132ab382fb2ba8ebde..8276c3a85a955e2902e32f7b69e8c8bd3fe2f74c 100644 (file)
@@ -40,6 +40,7 @@
 
 #include "../task_p.h"
 
+/* Set to true (or use -v option) for verbose output */
 static bool verbose = false;
 
 static isc_mutex_t lock;
index c958b6a9cda8d6f449181687cd0d71340072ad07..d964c7c8ccab2a5fcb0736834056699657c703ce 100644 (file)
@@ -36,7 +36,7 @@
 
 #include "isctest.h"
 
-/* Set to true for verbose output */
+/* Set to true (or use -v option) for verbose output */
 static bool verbose = false;
 
 #define        FUDGE_SECONDS   0            /* in absence of clock_getres() */