Commit 8f15219f authored by Evan Hunt's avatar Evan Hunt
Browse files

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

parent d4bad35b
Pipeline #6855 passed with stages
in 9 minutes and 8 seconds
......@@ -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();
}
......
......@@ -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);
}
......
......@@ -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));
}
......
......@@ -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,10 +35,13 @@
#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));
}
......
......@@ -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 */
}
......
......@@ -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() */
......
......@@ -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;
......
......@@ -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() */
......
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