db_test.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 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 <unistd.h>
00026 #include <stdlib.h>
00027 
00028 #include <dns/db.h>
00029 #include <dns/dbiterator.h>
00030 #include <dns/name.h>
00031 #include <dns/journal.h>
00032 
00033 #include "dnstest.h"
00034 
00035 /*
00036  * Helper functions
00037  */
00038 
00039 #define BUFLEN          255
00040 #define BIGBUFLEN       (64 * 1024)
00041 #define TEST_ORIGIN     "test"
00042 
00043 /*
00044  * Individual unit tests
00045  */
00046 
00047 ATF_TC(getoriginnode);
00048 ATF_TC_HEAD(getoriginnode, tc) {
00049         atf_tc_set_md_var(tc, "descr",
00050                           "test multiple calls to dns_db_getoriginnode");
00051 }
00052 ATF_TC_BODY(getoriginnode, tc) {
00053         dns_db_t *db = NULL;
00054         dns_dbnode_t *node = NULL;
00055         isc_mem_t *mymctx = NULL;
00056         isc_result_t result;
00057 
00058         result = isc_mem_create(0, 0, &mymctx);
00059         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00060 
00061         result = isc_hash_create(mymctx, NULL, 256);
00062         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00063 
00064         result = dns_db_create(mymctx, "rbt", dns_rootname, dns_dbtype_zone,
00065                             dns_rdataclass_in, 0, NULL, &db);
00066         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00067 
00068         result = dns_db_getoriginnode(db, &node);
00069         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00070         dns_db_detachnode(db, &node);
00071 
00072         result = dns_db_getoriginnode(db, &node);
00073         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00074         dns_db_detachnode(db, &node);
00075 
00076         dns_db_detach(&db);
00077         isc_mem_detach(&mymctx);
00078 }
00079 
00080 /*
00081  * Main
00082  */
00083 ATF_TP_ADD_TCS(tp) {
00084         ATF_TP_ADD_TC(tp, getoriginnode);
00085         return (atf_no_error());
00086 }

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