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"
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);
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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",
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);
}
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);
}
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);
}
/* 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);
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);
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);
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);
}
#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;
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);
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);
}
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);
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);
#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,
_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));
}