]> 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 21:00:49 +0000 (13:00 -0800)
(cherry picked from commit 8f15219f360f74e50a37df665ebe3d4e0e5acf98)

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/isc/tests/random_test.c
lib/isc/tests/regex_test.c
lib/isc/tests/task_test.c
lib/isc/tests/timer_test.c

index e6f01423209d29b5582fcc4b18bc611c8119ff3d..17da3f399885ecf8d60a444985dd69aa052d188f 100644 (file)
@@ -498,6 +498,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();
@@ -506,7 +508,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 305002cc288096460bd7d2d1bddef4bb55789b8e..b1b797dd98a8b9361023141526471117826b1480 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"
@@ -155,6 +164,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_loadfile2(testfile, &dns_origin, &dns_origin,
                                      dns_rdataclass_in, true,
                                      &callbacks, mctx, format);
@@ -178,7 +198,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);
 }
 
@@ -194,7 +214,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);
 }
 
@@ -210,7 +230,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);
 }
 
@@ -226,7 +246,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);
 }
 
@@ -242,7 +262,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);
 }
 
@@ -257,7 +277,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);
 }
 
@@ -272,7 +292,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);
 }
 
@@ -287,7 +307,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);
 }
 
@@ -303,7 +323,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);
 }
 
@@ -318,7 +338,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);
 }
 
@@ -333,7 +353,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_loadfile4("testdata/master/master8.data",
@@ -359,7 +379,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);
 }
 
@@ -374,7 +394,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);
 }
 
@@ -390,7 +410,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);
 }
 
@@ -441,21 +461,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);
@@ -504,7 +524,8 @@ dumpraw_test(void **state) {
                                  dns_masterformat_raw);
        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);
@@ -519,7 +540,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);
@@ -565,7 +587,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 e8fb91e6a80b80d2bda8942708f96bda12332d53..005ef9df05520a7c196de9c663d82d770e6dd425 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);
@@ -755,7 +771,7 @@ benchmark_test(void **state) {
 #endif /* ISC_PLATFORM_USETHREADS */
 
 int
-main(void) {
+main(int argc, char **argv) {
        const struct CMUnitTest tests[] = {
                cmocka_unit_test(fullcompare_test),
                cmocka_unit_test_setup_teardown(compression_test,
@@ -777,6 +793,18 @@ main(void) {
 #endif /* DNS_BENCHMARK_TESTS */
 #endif /* ISC_PLATFORM_USETHREADS */
        };
+       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, dns_test_init, dns_test_final));
 }
index b71d002c9dd356fb02f37657cba2a85c3fbe7bd0..55202378e328f99a28c30463faf5c1a3fd366da1 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/entropy.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>
@@ -62,6 +60,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;
@@ -315,7 +316,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.
@@ -350,7 +353,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);
@@ -450,7 +455,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),
@@ -458,6 +463,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, dns_test_init, dns_test_final));
 }
index 9fb3888cf6d816ce6280defe2cb6558cc2e2b487..228e300c9d28447b3aa38706635e9b28193a2aee 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 59f9cd11e6b98eee67dd4133d5563da2e8bfc4a1..4406cd621e29a1a4fafb9a3dcc7bcf7b1d84508f 100644 (file)
@@ -39,6 +39,7 @@
 #include "../task_p.h"
 #include "isctest.h"
 
+/* Set to true (or use -v option) for verbose output */
 static bool verbose = false;
 
 static isc_mutex_t lock;
index 6bc4b50160cf8f779f15706a14129be7529617ac..891dce557f7405699a24416b74e64bdb78f8d497 100644 (file)
@@ -41,7 +41,7 @@
  */
 #ifdef ISC_PLATFORM_USETHREADS
 
-/* 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() */