dbiterator_test.c revision d64e3b29bd1b66a4bc80b60ef87a5bafe741d7ca
/*
* Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
*
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dbiterator_test.c,v 1.5 2011/08/29 23:44:07 marka Exp $ */
/*! \file */
#include <config.h>
#include <atf-c.h>
#include <unistd.h>
#include <stdlib.h>
#include <dns/dbiterator.h>
#include "dnstest.h"
/*
* Helper functions
*/
#define BUFLEN 255
#define TEST_ORIGIN "test"
static isc_result_t
int len;
char origin[sizeof(TEST_ORIGIN)];
0, &target);
if (result != ISC_R_SUCCESS)
return(result);
if (result != ISC_R_SUCCESS)
return (result);
/*
* atf-run changes us to a /tmp directory, so tests
* that access test data files must first chdir to the proper
* location.
*/
return (ISC_R_FAILURE);
return (result);
}
static isc_result_t
isc_buffer_t b;
}
/*
* Individual unit tests
*/
/* create: make sure we can create a dbiterator */
static void
dns_dbtype_cache, &db);
dns_db_detach(&db);
dns_test_end();
}
}
}
}
}
/* walk: walk a database */
static void
int i = 0;
dns_fixedname_init(&f);
name = dns_fixedname_name(&f);
dns_dbtype_cache, &db);
result == ISC_R_SUCCESS;
if (result == DNS_R_NEWORIGIN)
i++;
}
dns_db_detach(&db);
dns_test_end();
}
}
}
}
}
/* reverse: walk database backwards */
int i = 0;
dns_fixedname_init(&f);
name = dns_fixedname_name(&f);
dns_dbtype_cache, &db);
result == ISC_R_SUCCESS;
if (result == DNS_R_NEWORIGIN)
i++;
}
ATF_CHECK_EQ(i, 12);
dns_db_detach(&db);
dns_test_end();
}
}
}
}
}
/* seek: walk database starting at a particular node */
int i = 0;
dns_dbtype_cache, &db);
while (result == ISC_R_SUCCESS) {
if (result == DNS_R_NEWORIGIN)
i++;
}
dns_db_detach(&db);
dns_test_end();
}
"a particular node");
}
}
"a particular node");
}
}
/*
* seek_emty: walk database starting at an empty nonterminal node
* (should fail)
*/
dns_dbtype_cache, &db);
dns_db_detach(&db);
dns_test_end();
}
"empty nonterminal node");
}
}
"empty nonterminal node");
}
}
/*
* seek_emty: walk database starting at an empty nonterminal node
* (should fail)
*/
dns_dbtype_cache, &db);
dns_db_detach(&db);
dns_test_end();
}
"at a nonexistent node");
}
}
"at a nonexistent node");
}
}
/*
* Main
*/
ATF_TP_ADD_TCS(tp) {
return (atf_no_error());
}
/*
* XXX:
* dns_dbiterator API calls that are not yet part of this unit test:
*
* dns_dbiterator_pause
* dns_dbiterator_origin
* dns_dbiterator_setcleanmode
*/