master_test.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2011-2013, 2015  Internet Systems Consortium, Inc. ("ISC")
00003  *
00004  * Permission to use, copy, modify, and/or distribute this software for any
00005  * purpose with or without fee is hereby granted, provided that the above
00006  * copyright notice and this permission notice appear in all copies.
00007  *
00008  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00009  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00010  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00011  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00012  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00013  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00014  * PERFORMANCE OF THIS SOFTWARE.
00015  */
00016 
00017 /* $Id$ */
00018 
00019 /*! \file */
00020 
00021 #include <config.h>
00022 
00023 #include <atf-c.h>
00024 
00025 #include <stdio.h>
00026 #include <unistd.h>
00027 
00028 #include <isc/print.h>
00029 #include <isc/xml.h>
00030 
00031 #include <dns/cache.h>
00032 #include <dns/callbacks.h>
00033 #include <dns/db.h>
00034 #include <dns/master.h>
00035 #include <dns/masterdump.h>
00036 #include <dns/name.h>
00037 #include <dns/rdata.h>
00038 #include <dns/rdatalist.h>
00039 #include <dns/rdataset.h>
00040 
00041 #include "dnstest.h"
00042 
00043 /*
00044  * Helper functions
00045  */
00046 
00047 #define BUFLEN          255
00048 #define BIGBUFLEN       (70 * 1024)
00049 #define TEST_ORIGIN     "test"
00050 
00051 static dns_masterrawheader_t header;
00052 static isc_boolean_t headerset;
00053 
00054 dns_name_t dns_origin;
00055 char origin[sizeof(TEST_ORIGIN)];
00056 unsigned char name_buf[BUFLEN];
00057 dns_rdatacallbacks_t callbacks;
00058 char *include_file = NULL;
00059 
00060 static isc_result_t
00061 add_callback(void *arg, dns_name_t *owner, dns_rdataset_t *dataset);
00062 
00063 static void
00064 rawdata_callback(dns_zone_t *zone, dns_masterrawheader_t *header);
00065 
00066 static isc_result_t
00067 add_callback(void *arg, dns_name_t *owner, dns_rdataset_t *dataset) {
00068         char buf[BIGBUFLEN];
00069         isc_buffer_t target;
00070         isc_result_t result;
00071 
00072         UNUSED(arg);
00073 
00074         isc_buffer_init(&target, buf, BIGBUFLEN);
00075         result = dns_rdataset_totext(dataset, owner, ISC_FALSE, ISC_FALSE,
00076                                      &target);
00077         return(result);
00078 }
00079 
00080 static void
00081 rawdata_callback(dns_zone_t *zone, dns_masterrawheader_t *h) {
00082         UNUSED(zone);
00083         header = *h;
00084         headerset = ISC_TRUE;
00085 }
00086 
00087 static isc_result_t
00088 setup_master(void (*warn)(struct dns_rdatacallbacks *, const char *, ...),
00089              void (*error)(struct dns_rdatacallbacks *, const char *, ...))
00090 {
00091         isc_result_t            result;
00092         int                     len;
00093         isc_buffer_t            source;
00094         isc_buffer_t            target;
00095 
00096         strcpy(origin, TEST_ORIGIN);
00097         len = strlen(origin);
00098         isc_buffer_init(&source, origin, len);
00099         isc_buffer_add(&source, len);
00100         isc_buffer_setactive(&source, len);
00101         isc_buffer_init(&target, name_buf, BUFLEN);
00102         dns_name_init(&dns_origin, NULL);
00103         dns_master_initrawheader(&header);
00104 
00105         result = dns_name_fromtext(&dns_origin, &source, dns_rootname,
00106                                    0, &target);
00107         if (result != ISC_R_SUCCESS)
00108                 return(result);
00109 
00110         dns_rdatacallbacks_init_stdio(&callbacks);
00111         callbacks.add = add_callback;
00112         callbacks.rawdata = rawdata_callback;
00113         callbacks.zone = NULL;
00114         if (warn != NULL)
00115                 callbacks.warn = warn;
00116         if (error != NULL)
00117                 callbacks.error = error;
00118         headerset = ISC_FALSE;
00119         return (result);
00120 }
00121 
00122 static isc_result_t
00123 test_master(const char *testfile, dns_masterformat_t format,
00124             void (*warn)(struct dns_rdatacallbacks *, const char *, ...),
00125             void (*error)(struct dns_rdatacallbacks *, const char *, ...))
00126 {
00127         isc_result_t            result;
00128 
00129         result = setup_master(warn, error);
00130         if (result != ISC_R_SUCCESS)
00131                 return(result);
00132 
00133         result = dns_master_loadfile2(testfile, &dns_origin, &dns_origin,
00134                                       dns_rdataclass_in, ISC_TRUE,
00135                                       &callbacks, mctx, format);
00136         return (result);
00137 }
00138 
00139 static void
00140 include_callback(const char *filename, void *arg) {
00141         char **argp = (char **) arg;
00142         *argp = isc_mem_strdup(mctx, filename);
00143 }
00144 
00145 /*
00146  * Individual unit tests
00147  */
00148 
00149 /* Successful load test */
00150 ATF_TC(load);
00151 ATF_TC_HEAD(load, tc) {
00152         atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() loads a "
00153                                        "valid master file and returns success");
00154 }
00155 ATF_TC_BODY(load, tc) {
00156         isc_result_t result;
00157 
00158         UNUSED(tc);
00159 
00160         result = dns_test_begin(NULL, ISC_FALSE);
00161         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00162 
00163         result = test_master("testdata/master/master1.data",
00164                              dns_masterformat_text, NULL, NULL);
00165         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00166 
00167         dns_test_end();
00168 }
00169 
00170 
00171 /* Unepxected end of file test */
00172 ATF_TC(unexpected);
00173 ATF_TC_HEAD(unexpected, tc) {
00174         atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() returns "
00175                                        "DNS_R_UNEXPECTED when file ends "
00176                                        "too soon");
00177 }
00178 ATF_TC_BODY(unexpected, tc) {
00179         isc_result_t result;
00180 
00181         UNUSED(tc);
00182 
00183         result = dns_test_begin(NULL, ISC_FALSE);
00184         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00185 
00186         result = test_master("testdata/master/master2.data",
00187                              dns_masterformat_text, NULL, NULL);
00188         ATF_REQUIRE_EQ(result, ISC_R_UNEXPECTEDEND);
00189 
00190         dns_test_end();
00191 }
00192 
00193 
00194 /* No owner test */
00195 ATF_TC(noowner);
00196 ATF_TC_HEAD(noowner, tc) {
00197         atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() accepts broken "
00198                                        "zones with no TTL for first record "
00199                                        "if it is an SOA");
00200 }
00201 ATF_TC_BODY(noowner, tc) {
00202         isc_result_t result;
00203 
00204         UNUSED(tc);
00205 
00206         result = dns_test_begin(NULL, ISC_FALSE);
00207         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00208 
00209         result = test_master("testdata/master/master3.data",
00210                              dns_masterformat_text, NULL, NULL);
00211         ATF_REQUIRE_EQ(result, DNS_R_NOOWNER);
00212 
00213         dns_test_end();
00214 }
00215 
00216 
00217 /* No TTL test */
00218 ATF_TC(nottl);
00219 ATF_TC_HEAD(nottl, tc) {
00220         atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() returns "
00221                                        "DNS_R_NOOWNER when no owner name "
00222                                        "is specified");
00223 }
00224 
00225 ATF_TC_BODY(nottl, tc) {
00226         isc_result_t result;
00227 
00228         UNUSED(tc);
00229 
00230         result = dns_test_begin(NULL, ISC_FALSE);
00231         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00232 
00233         result = test_master("testdata/master/master4.data",
00234                              dns_masterformat_text, NULL, NULL);
00235         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00236 
00237         dns_test_end();
00238 }
00239 
00240 
00241 /* Bad class test */
00242 ATF_TC(badclass);
00243 ATF_TC_HEAD(badclass, tc) {
00244         atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() returns "
00245                                        "DNS_R_BADCLASS when record class "
00246                                        "doesn't match zone class");
00247 }
00248 ATF_TC_BODY(badclass, tc) {
00249         isc_result_t result;
00250 
00251         UNUSED(tc);
00252 
00253         result = dns_test_begin(NULL, ISC_FALSE);
00254         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00255 
00256         result = test_master("testdata/master/master5.data",
00257                              dns_masterformat_text, NULL, NULL);
00258         ATF_REQUIRE_EQ(result, DNS_R_BADCLASS);
00259 
00260         dns_test_end();
00261 }
00262 
00263 /* Too big rdata test */
00264 ATF_TC(toobig);
00265 ATF_TC_HEAD(toobig, tc) {
00266         atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() returns "
00267                                        "ISC_R_NOSPACE when record is too big");
00268 }
00269 ATF_TC_BODY(toobig, tc) {
00270         isc_result_t result;
00271 
00272         UNUSED(tc);
00273 
00274         result = dns_test_begin(NULL, ISC_FALSE);
00275         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00276 
00277         result = test_master("testdata/master/master15.data",
00278                              dns_masterformat_text, NULL, NULL);
00279         ATF_REQUIRE_EQ(result, ISC_R_NOSPACE);
00280 
00281         dns_test_end();
00282 }
00283 
00284 /* Maximum rdata test */
00285 ATF_TC(maxrdata);
00286 ATF_TC_HEAD(maxrdata, tc) {
00287         atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() returns "
00288                                        "ISC_R_SUCCESS when record is maximum "
00289                                        "size");
00290 }
00291 ATF_TC_BODY(maxrdata, tc) {
00292         isc_result_t result;
00293 
00294         UNUSED(tc);
00295 
00296         result = dns_test_begin(NULL, ISC_FALSE);
00297         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00298 
00299         result = test_master("testdata/master/master16.data",
00300                              dns_masterformat_text, NULL, NULL);
00301         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00302 
00303         dns_test_end();
00304 }
00305 
00306 /* DNSKEY test */
00307 ATF_TC(dnskey);
00308 ATF_TC_HEAD(dnskey, tc) {
00309         atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() understands "
00310                                        "DNSKEY with key material");
00311 }
00312 ATF_TC_BODY(dnskey, tc) {
00313         isc_result_t result;
00314 
00315         UNUSED(tc);
00316 
00317         result = dns_test_begin(NULL, ISC_FALSE);
00318         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00319 
00320         result = test_master("testdata/master/master6.data",
00321                              dns_masterformat_text, NULL, NULL);
00322         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00323 
00324         dns_test_end();
00325 }
00326 
00327 
00328 /* DNSKEY with no key material test */
00329 ATF_TC(dnsnokey);
00330 ATF_TC_HEAD(dnsnokey, tc) {
00331         atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() understands "
00332                                        "DNSKEY with no key material");
00333 }
00334 ATF_TC_BODY(dnsnokey, tc) {
00335         isc_result_t result;
00336 
00337         UNUSED(tc);
00338 
00339         result = dns_test_begin(NULL, ISC_FALSE);
00340         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00341 
00342         result = test_master("testdata/master/master7.data",
00343                              dns_masterformat_text, NULL, NULL);
00344         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00345 
00346         dns_test_end();
00347 }
00348 
00349 /* Include test */
00350 ATF_TC(include);
00351 ATF_TC_HEAD(include, tc) {
00352         atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() understands "
00353                                        "$INCLUDE");
00354 }
00355 ATF_TC_BODY(include, tc) {
00356         isc_result_t result;
00357 
00358         UNUSED(tc);
00359 
00360         result = dns_test_begin(NULL, ISC_FALSE);
00361         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00362 
00363         result = test_master("testdata/master/master8.data",
00364                              dns_masterformat_text, NULL, NULL);
00365         ATF_REQUIRE_EQ(result, DNS_R_SEENINCLUDE);
00366 
00367         dns_test_end();
00368 }
00369 
00370 /* Include file list test */
00371 ATF_TC(master_includelist);
00372 ATF_TC_HEAD(master_includelist, tc) {
00373         atf_tc_set_md_var(tc, "descr", "dns_master_loadfile4() returns "
00374                                        "names of included file");
00375 }
00376 ATF_TC_BODY(master_includelist, tc) {
00377         isc_result_t result;
00378         char *filename = NULL;
00379 
00380         UNUSED(tc);
00381 
00382         result = dns_test_begin(NULL, ISC_FALSE);
00383         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00384 
00385         result = setup_master(NULL, NULL);
00386         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00387 
00388         result = dns_master_loadfile4("testdata/master/master8.data",
00389                                       &dns_origin, &dns_origin,
00390                                       dns_rdataclass_in, 0, ISC_TRUE,
00391                                       &callbacks, include_callback,
00392                                       &filename, mctx, dns_masterformat_text);
00393         ATF_CHECK_EQ(result, DNS_R_SEENINCLUDE);
00394         ATF_CHECK(filename != NULL);
00395         if (filename != NULL) {
00396                 ATF_CHECK_STREQ(filename, "testdata/master/master7.data");
00397                 isc_mem_free(mctx, filename);
00398         }
00399 
00400         dns_test_end();
00401 }
00402 
00403 /* Include failure test */
00404 ATF_TC(includefail);
00405 ATF_TC_HEAD(includefail, tc) {
00406         atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() understands "
00407                                        "$INCLUDE failures");
00408 }
00409 ATF_TC_BODY(includefail, tc) {
00410         isc_result_t result;
00411 
00412         UNUSED(tc);
00413 
00414         result = dns_test_begin(NULL, ISC_FALSE);
00415         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00416 
00417         result = test_master("testdata/master/master9.data",
00418                              dns_masterformat_text, NULL, NULL);
00419         ATF_REQUIRE_EQ(result, DNS_R_BADCLASS);
00420 
00421         dns_test_end();
00422 }
00423 
00424 
00425 /* Non-empty blank lines test */
00426 ATF_TC(blanklines);
00427 ATF_TC_HEAD(blanklines, tc) {
00428         atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() handles "
00429                                        "non-empty blank lines");
00430 }
00431 ATF_TC_BODY(blanklines, tc) {
00432         isc_result_t result;
00433 
00434         UNUSED(tc);
00435 
00436         result = dns_test_begin(NULL, ISC_FALSE);
00437         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00438 
00439         result = test_master("testdata/master/master10.data",
00440                              dns_masterformat_text, NULL, NULL);
00441         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00442 
00443         dns_test_end();
00444 }
00445 
00446 /* SOA leading zeroes test */
00447 ATF_TC(leadingzero);
00448 ATF_TC_HEAD(leadingzero, tc) {
00449         atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() allows "
00450                                        "leading zeroes in SOA");
00451 }
00452 ATF_TC_BODY(leadingzero, tc) {
00453         isc_result_t result;
00454 
00455         UNUSED(tc);
00456 
00457         result = dns_test_begin(NULL, ISC_FALSE);
00458         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00459 
00460         result = test_master("testdata/master/master11.data",
00461                              dns_masterformat_text, NULL, NULL);
00462         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00463 
00464         dns_test_end();
00465 }
00466 
00467 ATF_TC(totext);
00468 ATF_TC_HEAD(totext, tc) {
00469         atf_tc_set_md_var(tc, "descr", "masterfile totext tests");
00470 }
00471 ATF_TC_BODY(totext, tc) {
00472         isc_result_t result;
00473         dns_rdataset_t rdataset;
00474         dns_rdatalist_t rdatalist;
00475         isc_buffer_t target;
00476         unsigned char buf[BIGBUFLEN];
00477 
00478         UNUSED(tc);
00479 
00480         result = dns_test_begin(NULL, ISC_FALSE);
00481         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00482 
00483         /* First, test with an empty rdataset */
00484         dns_rdatalist_init(&rdatalist);
00485         rdatalist.rdclass = dns_rdataclass_in;
00486         rdatalist.type = dns_rdatatype_none;
00487         rdatalist.covers = dns_rdatatype_none;
00488 
00489         dns_rdataset_init(&rdataset);
00490         result = dns_rdatalist_tordataset(&rdatalist, &rdataset);
00491         ATF_CHECK_EQ(result, ISC_R_SUCCESS);
00492 
00493         isc_buffer_init(&target, buf, BIGBUFLEN);
00494         result = dns_master_rdatasettotext(dns_rootname,
00495                                            &rdataset, &dns_master_style_debug,
00496                                            &target);
00497         ATF_CHECK_EQ(result, ISC_R_SUCCESS);
00498         ATF_CHECK_EQ(isc_buffer_usedlength(&target), 0);
00499 
00500         /*
00501          * XXX: We will also need to add tests for dumping various
00502          * rdata types, classes, etc, and comparing the results against
00503          * known-good output.
00504          */
00505 
00506         dns_test_end();
00507 }
00508 
00509 /* Raw load */
00510 ATF_TC(loadraw);
00511 ATF_TC_HEAD(loadraw, tc) {
00512         atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() loads a "
00513                                        "valid raw file and returns success");
00514 }
00515 ATF_TC_BODY(loadraw, tc) {
00516         isc_result_t result;
00517 
00518         UNUSED(tc);
00519 
00520         result = dns_test_begin(NULL, ISC_FALSE);
00521         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00522 
00523         /* Raw format version 0 */
00524         result = test_master("testdata/master/master12.data",
00525                              dns_masterformat_raw, NULL, NULL);
00526         ATF_CHECK_STREQ(isc_result_totext(result), "success");
00527         ATF_CHECK(headerset);
00528         ATF_CHECK_EQ(header.flags, 0);
00529 
00530         /* Raw format version 1, no source serial  */
00531         result = test_master("testdata/master/master13.data",
00532                              dns_masterformat_raw, NULL, NULL);
00533         ATF_CHECK_STREQ(isc_result_totext(result), "success");
00534         ATF_CHECK(headerset);
00535         ATF_CHECK_EQ(header.flags, 0);
00536 
00537         /* Raw format version 1, source serial == 2011120101 */
00538         result = test_master("testdata/master/master14.data",
00539                              dns_masterformat_raw, NULL, NULL);
00540         ATF_CHECK_STREQ(isc_result_totext(result), "success");
00541         ATF_CHECK(headerset);
00542         ATF_CHECK((header.flags & DNS_MASTERRAW_SOURCESERIALSET) != 0);
00543         ATF_CHECK_EQ(header.sourceserial, 2011120101);
00544 
00545         dns_test_end();
00546 }
00547 
00548 /* Raw dump*/
00549 ATF_TC(dumpraw);
00550 ATF_TC_HEAD(dumpraw, tc) {
00551         atf_tc_set_md_var(tc, "descr", "dns_master_dump*() functions "
00552                                        "dump valid raw files");
00553 }
00554 ATF_TC_BODY(dumpraw, tc) {
00555         isc_result_t result;
00556         dns_db_t *db = NULL;
00557         dns_dbversion_t *version = NULL;
00558         char myorigin[sizeof(TEST_ORIGIN)];
00559         dns_name_t dnsorigin;
00560         isc_buffer_t source, target;
00561         unsigned char namebuf[BUFLEN];
00562         int len;
00563 
00564         UNUSED(tc);
00565 
00566         strcpy(myorigin, TEST_ORIGIN);
00567         len = strlen(myorigin);
00568         isc_buffer_init(&source, myorigin, len);
00569         isc_buffer_add(&source, len);
00570         isc_buffer_setactive(&source, len);
00571         isc_buffer_init(&target, namebuf, BUFLEN);
00572         dns_name_init(&dnsorigin, NULL);
00573         result = dns_name_fromtext(&dnsorigin, &source, dns_rootname,
00574                                    0, &target);
00575         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00576 
00577         result = dns_test_begin(NULL, ISC_FALSE);
00578         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00579 
00580         result = dns_db_create(mctx, "rbt", &dnsorigin, dns_dbtype_zone,
00581                                dns_rdataclass_in, 0, NULL, &db);
00582         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00583 
00584         result = dns_db_load(db, "testdata/master/master1.data");
00585         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00586 
00587         dns_db_currentversion(db, &version);
00588 
00589         result = dns_master_dump2(mctx, db, version,
00590                                   &dns_master_style_default, "test.dump",
00591                                   dns_masterformat_raw);
00592         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00593 
00594         result = test_master("test.dump", dns_masterformat_raw, NULL, NULL);
00595         ATF_CHECK_STREQ(isc_result_totext(result), "success");
00596         ATF_CHECK(headerset);
00597         ATF_CHECK_EQ(header.flags, 0);
00598 
00599         dns_master_initrawheader(&header);
00600         header.sourceserial = 12345;
00601         header.flags |= DNS_MASTERRAW_SOURCESERIALSET;
00602 
00603         unlink("test.dump");
00604         result = dns_master_dump3(mctx, db, version,
00605                                   &dns_master_style_default, "test.dump",
00606                                   dns_masterformat_raw, &header);
00607         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00608 
00609         result = test_master("test.dump", dns_masterformat_raw, NULL, NULL);
00610         ATF_CHECK_STREQ(isc_result_totext(result), "success");
00611         ATF_CHECK(headerset);
00612         ATF_CHECK((header.flags & DNS_MASTERRAW_SOURCESERIALSET) != 0);
00613         ATF_CHECK_EQ(header.sourceserial, 12345);
00614 
00615         unlink("test.dump");
00616         dns_db_closeversion(db, &version, ISC_FALSE);
00617         dns_db_detach(&db);
00618         dns_test_end();
00619 }
00620 
00621 static const char *warn_expect_value;
00622 static isc_boolean_t warn_expect_result;
00623 
00624 static void
00625 warn_expect(struct dns_rdatacallbacks *mycallbacks, const char *fmt, ...) {
00626         char buf[4096];
00627         va_list ap;
00628 
00629         UNUSED(mycallbacks);
00630 
00631         va_start(ap, fmt);
00632         vsnprintf(buf, sizeof(buf), fmt, ap);
00633         va_end(ap);
00634         if (warn_expect_value != NULL && strstr(buf, warn_expect_value) != NULL)
00635                 warn_expect_result = ISC_TRUE;
00636 }
00637 
00638 /* Origin change test */
00639 ATF_TC(neworigin);
00640 ATF_TC_HEAD(neworigin, tc) {
00641         atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() rejects "
00642                                        "zones with inherited name following "
00643                                        "$ORIGIN");
00644 }
00645 ATF_TC_BODY(neworigin, tc) {
00646         isc_result_t result;
00647 
00648         UNUSED(tc);
00649 
00650         result = dns_test_begin(NULL, ISC_FALSE);
00651         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00652 
00653         warn_expect_value = "record with inherited owner";
00654         warn_expect_result = ISC_FALSE;
00655         result = test_master("testdata/master/master17.data",
00656                              dns_masterformat_text, warn_expect, NULL);
00657         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00658         ATF_CHECK_MSG(warn_expect_result, "'%s' warning not emitted",
00659                       warn_expect_value);
00660 
00661         dns_test_end();
00662 }
00663 
00664 /*
00665  * Main
00666  */
00667 ATF_TP_ADD_TCS(tp) {
00668         ATF_TP_ADD_TC(tp, load);
00669         ATF_TP_ADD_TC(tp, unexpected);
00670         ATF_TP_ADD_TC(tp, noowner);
00671         ATF_TP_ADD_TC(tp, nottl);
00672         ATF_TP_ADD_TC(tp, badclass);
00673         ATF_TP_ADD_TC(tp, dnskey);
00674         ATF_TP_ADD_TC(tp, dnsnokey);
00675         ATF_TP_ADD_TC(tp, include);
00676         ATF_TP_ADD_TC(tp, master_includelist);
00677         ATF_TP_ADD_TC(tp, includefail);
00678         ATF_TP_ADD_TC(tp, blanklines);
00679         ATF_TP_ADD_TC(tp, leadingzero);
00680         ATF_TP_ADD_TC(tp, totext);
00681         ATF_TP_ADD_TC(tp, loadraw);
00682         ATF_TP_ADD_TC(tp, dumpraw);
00683         ATF_TP_ADD_TC(tp, toobig);
00684         ATF_TP_ADD_TC(tp, maxrdata);
00685         ATF_TP_ADD_TC(tp, neworigin);
00686 
00687         return (atf_no_error());
00688 }
00689 

Generated on Tue Apr 28 17:41:01 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha