From: Joey Date: Wed, 14 Nov 2018 12:18:19 +0000 (+0800) Subject: convert master_test X-Git-Tag: v9.13.4~21^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ba08bb119a150e8d9428074cba37f1e6850cf10;p=thirdparty%2Fbind9.git convert master_test --- diff --git a/lib/dns/tests/master_test.c b/lib/dns/tests/master_test.c index b024ed517b1..4557f8c2548 100644 --- a/lib/dns/tests/master_test.c +++ b/lib/dns/tests/master_test.c @@ -10,16 +10,24 @@ */ -/*! \file */ - #include -#include +#if HAVE_CMOCKA + +#include +#include +#include #include #include +#include #include +#define UNIT_TESTING +#include + +#include + #include #include #include @@ -36,9 +44,26 @@ #include "dnstest.h" -/* - * Helper functions - */ +static int +_setup(void **state) { + isc_result_t result; + + UNUSED(state); + + result = dns_test_begin(NULL, false); + assert_int_equal(result, ISC_R_SUCCESS); + + return (0); +} + +static int +_teardown(void **state) { + UNUSED(state); + + dns_test_end(); + + return (0); +} #define BUFLEN 255 #define BIGBUFLEN (70 * 1024) @@ -97,17 +122,20 @@ setup_master(void (*warn)(struct dns_rdatacallbacks *, const char *, ...), result = dns_name_fromtext(&dns_origin, &source, dns_rootname, 0, &target); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { return(result); + } dns_rdatacallbacks_init_stdio(&callbacks); callbacks.add = add_callback; callbacks.rawdata = rawdata_callback; callbacks.zone = NULL; - if (warn != NULL) + if (warn != NULL) { callbacks.warn = warn; - if (error != NULL) + } + if (error != NULL) { callbacks.error = error; + } headerset = false; return (result); } @@ -120,8 +148,9 @@ test_master(const char *testfile, dns_masterformat_t format, isc_result_t result; result = setup_master(warn, error); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { return(result); + } result = dns_master_loadfile(testfile, &dns_origin, &dns_origin, dns_rdataclass_in, true, 0, @@ -136,342 +165,243 @@ include_callback(const char *filename, void *arg) { } /* - * Individual unit tests + * Successful load test: + * dns_master_loadfile() loads a valid master file and returns success */ - -/* Successful load test */ -ATF_TC(load); -ATF_TC_HEAD(load, tc) { - atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() loads a " - "valid master file and returns success"); -} -ATF_TC_BODY(load, tc) { +static void +load_test(void **state) { isc_result_t result; - UNUSED(tc); - - result = dns_test_begin(NULL, false); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + UNUSED(state); result = test_master("testdata/master/master1.data", dns_masterformat_text, NULL, NULL); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - - dns_test_end(); + assert_int_equal(result, ISC_R_SUCCESS); } -/* Unepxected end of file test */ -ATF_TC(unexpected); -ATF_TC_HEAD(unexpected, tc) { - atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() returns " - "DNS_R_UNEXPECTED when file ends " - "too soon"); -} -ATF_TC_BODY(unexpected, tc) { +/* + * Unexpected end of file test: + * dns_master_loadfile() returns DNS_R_UNEXPECTED when file ends too soon + */ +static void +unexpected_test(void **state) { isc_result_t result; - UNUSED(tc); - - result = dns_test_begin(NULL, false); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + UNUSED(state); result = test_master("testdata/master/master2.data", dns_masterformat_text, NULL, NULL); - ATF_REQUIRE_EQ(result, ISC_R_UNEXPECTEDEND); - - dns_test_end(); + assert_int_equal(result, ISC_R_UNEXPECTEDEND); } - -/* No owner test */ -ATF_TC(noowner); -ATF_TC_HEAD(noowner, tc) { - atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() accepts broken " - "zones with no TTL for first record " - "if it is an SOA"); -} -ATF_TC_BODY(noowner, tc) { +/* + * No owner test: + * dns_master_loadfile() accepts broken zones with no TTL for first record + * if it is an SOA + */ +static void +noowner_test(void **state) { isc_result_t result; - UNUSED(tc); - - result = dns_test_begin(NULL, false); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + UNUSED(state); result = test_master("testdata/master/master3.data", dns_masterformat_text, NULL, NULL); - ATF_REQUIRE_EQ(result, DNS_R_NOOWNER); - - dns_test_end(); -} - - -/* No TTL test */ -ATF_TC(nottl); -ATF_TC_HEAD(nottl, tc) { - atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() returns " - "DNS_R_NOOWNER when no owner name " - "is specified"); + assert_int_equal(result, DNS_R_NOOWNER); } -ATF_TC_BODY(nottl, tc) { +/* + * No TTL test: + * dns_master_loadfile() returns DNS_R_NOOWNER when no owner name is + * specified + */ +static void +nottl_test(void **state) { isc_result_t result; - UNUSED(tc); - - result = dns_test_begin(NULL, false); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + UNUSED(state); result = test_master("testdata/master/master4.data", dns_masterformat_text, NULL, NULL); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - - dns_test_end(); + assert_int_equal(result, ISC_R_SUCCESS); } - -/* Bad class test */ -ATF_TC(badclass); -ATF_TC_HEAD(badclass, tc) { - atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() returns " - "DNS_R_BADCLASS when record class " - "doesn't match zone class"); -} -ATF_TC_BODY(badclass, tc) { +/* + * Bad class test: + * dns_master_loadfile() returns DNS_R_BADCLASS when record class doesn't + * match zone class + */ +static void +badclass_test(void **state) { isc_result_t result; - UNUSED(tc); - - result = dns_test_begin(NULL, false); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + UNUSED(state); result = test_master("testdata/master/master5.data", dns_masterformat_text, NULL, NULL); - ATF_REQUIRE_EQ(result, DNS_R_BADCLASS); - - dns_test_end(); + assert_int_equal(result, DNS_R_BADCLASS); } -/* Too big rdata test */ -ATF_TC(toobig); -ATF_TC_HEAD(toobig, tc) { - atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() returns " - "ISC_R_NOSPACE when record is too big"); -} -ATF_TC_BODY(toobig, tc) { +/* + * Too big rdata test: + * dns_master_loadfile() returns ISC_R_NOSPACE when record is too big + */ +static void +toobig_test(void **state) { isc_result_t result; - UNUSED(tc); - - result = dns_test_begin(NULL, false); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + UNUSED(state); result = test_master("testdata/master/master15.data", dns_masterformat_text, NULL, NULL); - ATF_REQUIRE_EQ(result, ISC_R_NOSPACE); - - dns_test_end(); + assert_int_equal(result, ISC_R_NOSPACE); } -/* Maximum rdata test */ -ATF_TC(maxrdata); -ATF_TC_HEAD(maxrdata, tc) { - atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() returns " - "ISC_R_SUCCESS when record is maximum " - "size"); -} -ATF_TC_BODY(maxrdata, tc) { +/* + * Maximum rdata test: + * dns_master_loadfile() returns ISC_R_SUCCESS when record is maximum size + */ +static void +maxrdata_test(void **state) { isc_result_t result; - UNUSED(tc); - - result = dns_test_begin(NULL, false); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + UNUSED(state); result = test_master("testdata/master/master16.data", dns_masterformat_text, NULL, NULL); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - - dns_test_end(); + assert_int_equal(result, ISC_R_SUCCESS); } -/* DNSKEY test */ -ATF_TC(dnskey); -ATF_TC_HEAD(dnskey, tc) { - atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() understands " - "DNSKEY with key material"); -} -ATF_TC_BODY(dnskey, tc) { +/* + * DNSKEY test: + * dns_master_loadfile() understands DNSKEY with key material + */ +static void +dnskey_test(void **state) { isc_result_t result; - UNUSED(tc); - - result = dns_test_begin(NULL, false); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + UNUSED(state); result = test_master("testdata/master/master6.data", dns_masterformat_text, NULL, NULL); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - - dns_test_end(); + assert_int_equal(result, ISC_R_SUCCESS); } -/* DNSKEY with no key material test */ -ATF_TC(dnsnokey); -ATF_TC_HEAD(dnsnokey, tc) { - atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() understands " - "DNSKEY with no key material"); -} -ATF_TC_BODY(dnsnokey, tc) { +/* + * DNSKEY with no key material test: + * dns_master_loadfile() understands DNSKEY with no key material + */ +static void +dnsnokey_test(void **state) { isc_result_t result; - UNUSED(tc); - - result = dns_test_begin(NULL, false); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + UNUSED(state); result = test_master("testdata/master/master7.data", dns_masterformat_text, NULL, NULL); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - - dns_test_end(); + assert_int_equal(result, ISC_R_SUCCESS); } -/* Include test */ -ATF_TC(include); -ATF_TC_HEAD(include, tc) { - atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() understands " - "$INCLUDE"); -} -ATF_TC_BODY(include, tc) { +/* + * Include test: + * dns_master_loadfile() understands $INCLUDE + */ +static void +include_test(void **state) { isc_result_t result; - UNUSED(tc); - - result = dns_test_begin(NULL, false); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + UNUSED(state); result = test_master("testdata/master/master8.data", dns_masterformat_text, NULL, NULL); - ATF_REQUIRE_EQ(result, DNS_R_SEENINCLUDE); - - dns_test_end(); + assert_int_equal(result, DNS_R_SEENINCLUDE); } -/* Include file list test */ -ATF_TC(master_includelist); -ATF_TC_HEAD(master_includelist, tc) { - atf_tc_set_md_var(tc, "descr", "dns_master_loadfile4() returns " - "names of included file"); -} -ATF_TC_BODY(master_includelist, tc) { +/* + * Include file list test: + * dns_master_loadfile4() returns names of included file + */ +static void +master_includelist_test(void **state) { isc_result_t result; char *filename = NULL; - UNUSED(tc); - - result = dns_test_begin(NULL, false); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + UNUSED(state); result = setup_master(NULL, NULL); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + assert_int_equal(result, ISC_R_SUCCESS); result = dns_master_loadfile("testdata/master/master8.data", &dns_origin, &dns_origin, dns_rdataclass_in, 0, true, &callbacks, include_callback, &filename, mctx, dns_masterformat_text, 0); - ATF_CHECK_EQ(result, DNS_R_SEENINCLUDE); - ATF_CHECK(filename != NULL); + assert_int_equal(result, DNS_R_SEENINCLUDE); + assert_non_null(filename); if (filename != NULL) { - ATF_CHECK_STREQ(filename, "testdata/master/master7.data"); + assert_string_equal(filename, "testdata/master/master7.data"); isc_mem_free(mctx, filename); } - - dns_test_end(); } -/* Include failure test */ -ATF_TC(includefail); -ATF_TC_HEAD(includefail, tc) { - atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() understands " - "$INCLUDE failures"); -} -ATF_TC_BODY(includefail, tc) { +/* + * Include failure test: + * dns_master_loadfile() understands $INCLUDE failures + */ +static void +includefail_test(void **state) { isc_result_t result; - UNUSED(tc); - - result = dns_test_begin(NULL, false); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + UNUSED(state); result = test_master("testdata/master/master9.data", dns_masterformat_text, NULL, NULL); - ATF_REQUIRE_EQ(result, DNS_R_BADCLASS); - - dns_test_end(); + assert_int_equal(result, DNS_R_BADCLASS); } - -/* Non-empty blank lines test */ -ATF_TC(blanklines); -ATF_TC_HEAD(blanklines, tc) { - atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() handles " - "non-empty blank lines"); -} -ATF_TC_BODY(blanklines, tc) { +/* + * Non-empty blank lines test: + * dns_master_loadfile() handles non-empty blank lines + */ +static void +blanklines_test(void **state) { isc_result_t result; - UNUSED(tc); - - result = dns_test_begin(NULL, false); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + UNUSED(state); result = test_master("testdata/master/master10.data", dns_masterformat_text, NULL, NULL); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - - dns_test_end(); + assert_int_equal(result, ISC_R_SUCCESS); } -/* SOA leading zeroes test */ -ATF_TC(leadingzero); -ATF_TC_HEAD(leadingzero, tc) { - atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() allows " - "leading zeroes in SOA"); -} -ATF_TC_BODY(leadingzero, tc) { - isc_result_t result; +/* + * SOA leading zeroes test: + * dns_master_loadfile() allows leading zeroes in SOA + */ - UNUSED(tc); +static void +leadingzero_test(void **state) { + isc_result_t result; - result = dns_test_begin(NULL, false); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + UNUSED(state); result = test_master("testdata/master/master11.data", dns_masterformat_text, NULL, NULL); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - - dns_test_end(); + assert_int_equal(result, ISC_R_SUCCESS); } -ATF_TC(totext); -ATF_TC_HEAD(totext, tc) { - atf_tc_set_md_var(tc, "descr", "masterfile totext tests"); -} -ATF_TC_BODY(totext, tc) { +/* masterfile totext tests */ +static void +totext_test(void **state) { isc_result_t result; dns_rdataset_t rdataset; dns_rdatalist_t rdatalist; isc_buffer_t target; unsigned char buf[BIGBUFLEN]; - UNUSED(tc); - - result = dns_test_begin(NULL, false); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + UNUSED(state); /* First, test with an empty rdataset */ dns_rdatalist_init(&rdatalist); @@ -481,70 +411,61 @@ ATF_TC_BODY(totext, tc) { dns_rdataset_init(&rdataset); result = dns_rdatalist_tordataset(&rdatalist, &rdataset); - ATF_CHECK_EQ(result, ISC_R_SUCCESS); + assert_int_equal(result, ISC_R_SUCCESS); isc_buffer_init(&target, buf, BIGBUFLEN); result = dns_master_rdatasettotext(dns_rootname, &rdataset, &dns_master_style_debug, &target); - ATF_CHECK_EQ(result, ISC_R_SUCCESS); - ATF_CHECK_EQ(isc_buffer_usedlength(&target), 0); + assert_int_equal(result, ISC_R_SUCCESS); + assert_int_equal(isc_buffer_usedlength(&target), 0); /* * XXX: We will also need to add tests for dumping various * rdata types, classes, etc, and comparing the results against * known-good output. */ - - dns_test_end(); } -/* Raw load */ -ATF_TC(loadraw); -ATF_TC_HEAD(loadraw, tc) { - atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() loads a " - "valid raw file and returns success"); -} -ATF_TC_BODY(loadraw, tc) { +/* + * Raw load test: + * dns_master_loadfile() loads a valid raw file and returns success + */ +static void +loadraw_test(void **state) { isc_result_t result; - UNUSED(tc); - - result = dns_test_begin(NULL, false); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + UNUSED(state); /* Raw format version 0 */ result = test_master("testdata/master/master12.data", dns_masterformat_raw, NULL, NULL); - ATF_CHECK_STREQ(isc_result_totext(result), "success"); - ATF_CHECK(headerset); - ATF_CHECK_EQ(header.flags, 0); + 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); - ATF_CHECK_STREQ(isc_result_totext(result), "success"); - ATF_CHECK(headerset); - ATF_CHECK_EQ(header.flags, 0); + 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); - ATF_CHECK_STREQ(isc_result_totext(result), "success"); - ATF_CHECK(headerset); - ATF_CHECK((header.flags & DNS_MASTERRAW_SOURCESERIALSET) != 0); - ATF_CHECK_EQ(header.sourceserial, 2011120101); - - dns_test_end(); + assert_string_equal(isc_result_totext(result), "success"); + assert_true(headerset); + assert_true((header.flags & DNS_MASTERRAW_SOURCESERIALSET) != 0); + assert_int_equal(header.sourceserial, 2011120101); } -/* Raw dump*/ -ATF_TC(dumpraw); -ATF_TC_HEAD(dumpraw, tc) { - atf_tc_set_md_var(tc, "descr", "dns_master_dump*() functions " - "dump valid raw files"); -} -ATF_TC_BODY(dumpraw, tc) { +/* + * Raw dump test: + * dns_master_dump*() functions dump valid raw files + */ +static void +dumpraw_test(void **state) { isc_result_t result; dns_db_t *db = NULL; dns_dbversion_t *version = NULL; @@ -554,7 +475,7 @@ ATF_TC_BODY(dumpraw, tc) { unsigned char namebuf[BUFLEN]; int len; - UNUSED(tc); + UNUSED(state); strlcpy(myorigin, TEST_ORIGIN, sizeof(myorigin)); len = strlen(myorigin); @@ -565,30 +486,27 @@ ATF_TC_BODY(dumpraw, tc) { dns_name_init(&dnsorigin, NULL); result = dns_name_fromtext(&dnsorigin, &source, dns_rootname, 0, &target); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - - result = dns_test_begin(NULL, false); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + assert_int_equal(result, ISC_R_SUCCESS); result = dns_db_create(mctx, "rbt", &dnsorigin, dns_dbtype_zone, dns_rdataclass_in, 0, NULL, &db); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + assert_int_equal(result, ISC_R_SUCCESS); result = dns_db_load(db, "testdata/master/master1.data", dns_masterformat_text, 0); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + assert_int_equal(result, ISC_R_SUCCESS); dns_db_currentversion(db, &version); result = dns_master_dump(mctx, db, version, &dns_master_style_default, "test.dump", dns_masterformat_raw, NULL); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + assert_int_equal(result, ISC_R_SUCCESS); result = test_master("test.dump", dns_masterformat_raw, NULL, NULL); - ATF_CHECK_STREQ(isc_result_totext(result), "success"); - ATF_CHECK(headerset); - ATF_CHECK_EQ(header.flags, 0); + assert_string_equal(isc_result_totext(result), "success"); + assert_true(headerset); + assert_int_equal(header.flags, 0); dns_master_initrawheader(&header); header.sourceserial = 12345; @@ -598,18 +516,17 @@ ATF_TC_BODY(dumpraw, tc) { result = dns_master_dump(mctx, db, version, &dns_master_style_default, "test.dump", dns_masterformat_raw, &header); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + assert_int_equal(result, ISC_R_SUCCESS); result = test_master("test.dump", dns_masterformat_raw, NULL, NULL); - ATF_CHECK_STREQ(isc_result_totext(result), "success"); - ATF_CHECK(headerset); - ATF_CHECK((header.flags & DNS_MASTERRAW_SOURCESERIALSET) != 0); - ATF_CHECK_EQ(header.sourceserial, 12345); + assert_string_equal(isc_result_totext(result), "success"); + assert_true(headerset); + assert_true((header.flags & DNS_MASTERRAW_SOURCESERIALSET) != 0); + assert_int_equal(header.sourceserial, 12345); unlink("test.dump"); dns_db_closeversion(db, &version, false); dns_db_detach(&db); - dns_test_end(); } static const char *warn_expect_value; @@ -622,62 +539,88 @@ warn_expect(struct dns_rdatacallbacks *mycallbacks, const char *fmt, ...) { UNUSED(mycallbacks); + warn_expect_result = false; + va_start(ap, fmt); vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); - if (warn_expect_value != NULL && strstr(buf, warn_expect_value) != NULL) + + if (warn_expect_value != NULL && + strstr(buf, warn_expect_value) != NULL) + { warn_expect_result = true; + } } -/* Origin change test */ -ATF_TC(neworigin); -ATF_TC_HEAD(neworigin, tc) { - atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() rejects " - "zones with inherited name following " - "$ORIGIN"); -} -ATF_TC_BODY(neworigin, tc) { +/* + * Origin change test: + * dns_master_loadfile() rejects zones with inherited name following $ORIGIN + */ +static void +neworigin_test(void **state) { isc_result_t result; - UNUSED(tc); - - result = dns_test_begin(NULL, false); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + UNUSED(state); warn_expect_value = "record with inherited owner"; - warn_expect_result = false; result = test_master("testdata/master/master17.data", dns_masterformat_text, warn_expect, NULL); - ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); - ATF_CHECK_MSG(warn_expect_result, "'%s' warning not emitted", - warn_expect_value); + assert_int_equal(result, ISC_R_SUCCESS); + assert_true(warn_expect_result); +} + +int +main(void) { + const struct CMUnitTest tests[] = { + cmocka_unit_test_setup_teardown(load_test, + _setup, _teardown), + cmocka_unit_test_setup_teardown(unexpected_test, + _setup, _teardown), + cmocka_unit_test_setup_teardown(noowner_test, + _setup, _teardown), + cmocka_unit_test_setup_teardown(nottl_test, + _setup, _teardown), + cmocka_unit_test_setup_teardown(badclass_test, + _setup, _teardown), + cmocka_unit_test_setup_teardown(dnskey_test, + _setup, _teardown), + cmocka_unit_test_setup_teardown(dnsnokey_test, + _setup, _teardown), + cmocka_unit_test_setup_teardown(include_test, + _setup, _teardown), + cmocka_unit_test_setup_teardown(master_includelist_test, + _setup, _teardown), + cmocka_unit_test_setup_teardown(includefail_test, + _setup, _teardown), + cmocka_unit_test_setup_teardown(blanklines_test, + _setup, _teardown), + cmocka_unit_test_setup_teardown(leadingzero_test, + _setup, _teardown), + cmocka_unit_test_setup_teardown(totext_test, + _setup, _teardown), + cmocka_unit_test_setup_teardown(loadraw_test, + _setup, _teardown), + cmocka_unit_test_setup_teardown(dumpraw_test, + _setup, _teardown), + cmocka_unit_test_setup_teardown(toobig_test, + _setup, _teardown), + cmocka_unit_test_setup_teardown(maxrdata_test, + _setup, _teardown), + cmocka_unit_test_setup_teardown(neworigin_test, + _setup, _teardown), + }; + + return (cmocka_run_group_tests(tests, NULL, NULL)); +} + +#else /* HAVE_CMOCKA */ - dns_test_end(); -} +#include -/* - * Main - */ -ATF_TP_ADD_TCS(tp) { - ATF_TP_ADD_TC(tp, load); - ATF_TP_ADD_TC(tp, unexpected); - ATF_TP_ADD_TC(tp, noowner); - ATF_TP_ADD_TC(tp, nottl); - ATF_TP_ADD_TC(tp, badclass); - ATF_TP_ADD_TC(tp, dnskey); - ATF_TP_ADD_TC(tp, dnsnokey); - ATF_TP_ADD_TC(tp, include); - ATF_TP_ADD_TC(tp, master_includelist); - ATF_TP_ADD_TC(tp, includefail); - ATF_TP_ADD_TC(tp, blanklines); - ATF_TP_ADD_TC(tp, leadingzero); - ATF_TP_ADD_TC(tp, totext); - ATF_TP_ADD_TC(tp, loadraw); - ATF_TP_ADD_TC(tp, dumpraw); - ATF_TP_ADD_TC(tp, toobig); - ATF_TP_ADD_TC(tp, maxrdata); - ATF_TP_ADD_TC(tp, neworigin); - - return (atf_no_error()); +int +main(void) { + printf("1..0 # Skipped: cmocka not available\n"); + return (0); } +#endif