Commit 58314571 authored by Evan Hunt's avatar Evan Hunt
Browse files

remove (or hide behind a 'verbose' flag) extra output from system tests

(cherry picked from commit 8f15219f)
parent 88414567
Pipeline #6860 passed with stages
in 7 minutes and 54 seconds
......@@ -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();
}
......
......@@ -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);
}
......
......@@ -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));
}
......
......@@ -27,11 +27,6 @@
#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>
......@@ -40,11 +35,14 @@
#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));
}
......
......@@ -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 {
......
......@@ -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() */
......
......@@ -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;
......
......@@ -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() */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment