rbt_test.c File Reference

#include <config.h>
#include <atf-c.h>
#include <isc/mem.h>
#include <isc/random.h>
#include <isc/string.h>
#include <fcntl.h>
#include <unistd.h>
#include <dns/rbt.h>
#include <dns/fixedname.h>
#include <dns/result.h>
#include <dns/compress.h>
#include "dnstest.h"
#include <isc/app.h>
#include <isc/buffer.h>
#include <isc/entropy.h>
#include <isc/file.h>
#include <isc/hash.h>
#include <isc/os.h>
#include <isc/socket.h>
#include <isc/stdio.h>
#include <isc/task.h>
#include <isc/timer.h>
#include <isc/util.h>
#include <isc/print.h>
#include <dns/log.h>
#include <dns/name.h>
#include <dst/dst.h>
#include <ctype.h>

Go to the source code of this file.

Data Structures

struct  test_context_t

Functions

static void delete_data (void *data, void *arg)
static void build_name_from_str (const char *namestr, dns_fixedname_t *fname)
static test_context_ttest_context_setup (void)
static void test_context_teardown (test_context_t *ctx)
static void check_test_data (dns_rbt_t *rbt)
 ATF_TC (rbt_create)
 ATF_TC_HEAD (rbt_create, tc)
 ATF_TC_BODY (rbt_create, tc)
 ATF_TC (rbt_nodecount)
 ATF_TC_HEAD (rbt_nodecount, tc)
 ATF_TC_BODY (rbt_nodecount, tc)
 ATF_TC (rbtnode_get_distance)
 ATF_TC_HEAD (rbtnode_get_distance, tc)
 ATF_TC_BODY (rbtnode_get_distance, tc)
 ATF_TC (rbt_check_distance_random)
 ATF_TC_HEAD (rbt_check_distance_random, tc)
 ATF_TC_BODY (rbt_check_distance_random, tc)
 ATF_TC (rbt_check_distance_ordered)
 ATF_TC_HEAD (rbt_check_distance_ordered, tc)
 ATF_TC_BODY (rbt_check_distance_ordered, tc)
static isc_result_t insert_helper (dns_rbt_t *rbt, const char *namestr, dns_rbtnode_t **node)
static isc_boolean_t compare_labelsequences (dns_rbtnode_t *node, const char *labelstr)
 ATF_TC (rbt_insert)
 ATF_TC_HEAD (rbt_insert, tc)
 ATF_TC_BODY (rbt_insert, tc)
 ATF_TC (rbt_remove)
 ATF_TC_HEAD (rbt_remove, tc)
 ATF_TC_BODY (rbt_remove, tc)
 ATF_TC (rbt_remove_empty)
 ATF_TC_HEAD (rbt_remove_empty, tc)
 ATF_TC_BODY (rbt_remove_empty, tc)
static void insert_nodes (dns_rbt_t *mytree, char **names, size_t *names_count, isc_uint32_t num_names)
static void remove_nodes (dns_rbt_t *mytree, char **names, size_t *names_count, isc_uint32_t num_names)
static void check_tree (dns_rbt_t *mytree, char **names, size_t names_count)
 ATF_TC (rbt_insert_and_remove)
 ATF_TC_HEAD (rbt_insert_and_remove, tc)
 ATF_TC_BODY (rbt_insert_and_remove, tc)
 ATF_TP_ADD_TCS (tp)

Variables

static const char *const domain_names []
static const size_t domain_names_count
static const int node_distances []
static const char *const ordered_names []
static const size_t ordered_names_count


Function Documentation

static void delete_data ( void *  data,
void *  arg 
) [static]

Definition at line 134 of file rbt_test.c.

References isc_mem_put, mctx, and UNUSED.

static void build_name_from_str ( const char *  namestr,
dns_fixedname_t fname 
) [static]

Definition at line 141 of file rbt_test.c.

References dns_fixedname_init, dns_fixedname_name, dns_name_fromtext(), dns_rootname, isc_buffer_allocate(), isc_buffer_free(), isc_buffer_putmem, ISC_R_SUCCESS, mctx, and name.

Referenced by ATF_TC_BODY(), check_test_data(), insert_helper(), insert_nodes(), remove_nodes(), and test_context_setup().

static test_context_t* test_context_setup ( void   )  [static]

Definition at line 163 of file rbt_test.c.

References build_name_from_str(), delete_data(), dns_fixedname_name, dns_rbt_addname(), dns_rbt_create(), domain_names, domain_names_count, isc_mem_get, ISC_R_SUCCESS, mctx, name, test_context_t::rbt, and test_context_t::rbt_distances.

Referenced by ATF_TC_BODY().

static void test_context_teardown ( test_context_t ctx  )  [static]

Definition at line 203 of file rbt_test.c.

References dns_rbt_destroy(), isc_mem_put, mctx, test_context_t::rbt, and test_context_t::rbt_distances.

Referenced by ATF_TC_BODY().

static void check_test_data ( dns_rbt_t rbt  )  [static]

Definition at line 214 of file rbt_test.c.

References build_name_from_str(), dns_fixedname_init, dns_fixedname_name, dns_rbt_findname(), domain_names, domain_names_count, fixed, ISC_R_SUCCESS, and name.

ATF_TC ( rbt_create   ) 

ATF_TC_HEAD ( rbt_create  ,
tc   
)

Definition at line 240 of file rbt_test.c.

ATF_TC_BODY ( rbt_create  ,
tc   
)

Definition at line 243 of file rbt_test.c.

References check_test_data(), dns__rbt_checkproperties(), dns_test_begin(), dns_test_end(), isc_mem_debugging, ISC_MEM_DEBUGRECORD, ISC_R_SUCCESS, ISC_TRUE, test_context_t::rbt, test_context_setup(), test_context_teardown(), and UNUSED.

ATF_TC ( rbt_nodecount   ) 

ATF_TC_HEAD ( rbt_nodecount  ,
tc   
)

Definition at line 268 of file rbt_test.c.

ATF_TC_BODY ( rbt_nodecount  ,
tc   
)

Definition at line 271 of file rbt_test.c.

References dns_rbt_nodecount(), dns_test_begin(), dns_test_end(), isc_mem_debugging, ISC_MEM_DEBUGRECORD, ISC_R_SUCCESS, ISC_TRUE, test_context_t::rbt, test_context_setup(), test_context_teardown(), and UNUSED.

ATF_TC ( rbtnode_get_distance   ) 

ATF_TC_HEAD ( rbtnode_get_distance  ,
tc   
)

Definition at line 292 of file rbt_test.c.

ATF_TC_BODY ( rbtnode_get_distance  ,
tc   
)

Definition at line 296 of file rbt_test.c.

References build_name_from_str(), dns_rbtnode::data, dns__rbtnode_getdistance(), dns_fixedname_name, dns_rbt_findnode(), dns_rbtnodechain_current(), dns_rbtnodechain_init(), dns_rbtnodechain_invalidate(), dns_rbtnodechain_next(), dns_test_begin(), dns_test_end(), isc_mem_debugging, ISC_MEM_DEBUGRECORD, ISC_R_NOMORE, ISC_R_SUCCESS, ISC_TRUE, mctx, name, test_context_t::rbt_distances, test_context_setup(), test_context_teardown(), and UNUSED.

ATF_TC ( rbt_check_distance_random   ) 

ATF_TC_HEAD ( rbt_check_distance_random  ,
tc   
)

Definition at line 344 of file rbt_test.c.

ATF_TC_BODY ( rbt_check_distance_random  ,
tc   
)

Definition at line 348 of file rbt_test.c.

References build_name_from_str(), delete_data(), dns__rbt_checkproperties(), dns__rbt_getheight(), dns_fixedname_name, dns_rbt_addname(), dns_rbt_create(), dns_rbt_destroy(), dns_rbt_nodecount(), dns_test_begin(), dns_test_end(), isc_mem_debugging, ISC_MEM_DEBUGRECORD, isc_mem_get, ISC_R_SUCCESS, isc_random_get(), ISC_TRUE, mctx, name, namebuf, and UNUSED.

ATF_TC ( rbt_check_distance_ordered   ) 

ATF_TC_HEAD ( rbt_check_distance_ordered  ,
tc   
)

Definition at line 428 of file rbt_test.c.

ATF_TC_BODY ( rbt_check_distance_ordered  ,
tc   
)

Definition at line 432 of file rbt_test.c.

References build_name_from_str(), delete_data(), dns__rbt_checkproperties(), dns__rbt_getheight(), dns_fixedname_name, dns_rbt_addname(), dns_rbt_create(), dns_rbt_destroy(), dns_rbt_nodecount(), dns_test_begin(), dns_test_end(), isc_mem_debugging, ISC_MEM_DEBUGRECORD, isc_mem_get, ISC_R_SUCCESS, ISC_TRUE, mctx, name, namebuf, and UNUSED.

static isc_result_t insert_helper ( dns_rbt_t rbt,
const char *  namestr,
dns_rbtnode_t **  node 
) [static]

Definition at line 500 of file rbt_test.c.

References build_name_from_str(), dns_fixedname_name, dns_rbt_addnode(), and name.

Referenced by ATF_TC_BODY().

static isc_boolean_t compare_labelsequences ( dns_rbtnode_t node,
const char *  labelstr 
) [static]

Definition at line 511 of file rbt_test.c.

References dns_name_init(), dns_name_tostring(), dns_rbt_namefromnode(), ISC_FALSE, isc_mem_free, ISC_R_SUCCESS, ISC_TRUE, mctx, and name.

Referenced by ATF_TC_BODY().

ATF_TC ( rbt_insert   ) 

ATF_TC_HEAD ( rbt_insert  ,
tc   
)

Definition at line 531 of file rbt_test.c.

ATF_TC_BODY ( rbt_insert  ,
tc   
)

Definition at line 534 of file rbt_test.c.

References compare_labelsequences(), dns_rbtnode::data, dns_rbt_nodecount(), dns_test_begin(), dns_test_end(), insert_helper(), isc_mem_debugging, ISC_MEM_DEBUGRECORD, ISC_R_EXISTS, ISC_R_SUCCESS, ISC_TRUE, test_context_t::rbt, test_context_setup(), test_context_teardown(), and UNUSED.

ATF_TC ( rbt_remove   ) 

ATF_TC_HEAD ( rbt_remove  ,
tc   
)

Definition at line 693 of file rbt_test.c.

ATF_TC_BODY ( rbt_remove  ,
tc   
)

Definition at line 696 of file rbt_test.c.

References build_name_from_str(), dns_rbtnode::data, delete_data(), dns__rbt_checkproperties(), dns_fixedname_name, dns_name_equal(), dns_rbt_create(), dns_rbt_deletename(), dns_rbt_destroy(), dns_rbt_findnode(), DNS_RBTFIND_EMPTYDATA, dns_rbtnodechain_current(), dns_rbtnodechain_init(), dns_rbtnodechain_next(), dns_test_begin(), dns_test_end(), domain_names, domain_names_count, insert_helper(), ISC_FALSE, isc_mem_debugging, ISC_MEM_DEBUGRECORD, isc_mem_get, ISC_R_NOMORE, ISC_R_NOTFOUND, ISC_R_SUCCESS, ISC_TRUE, mctx, name, and UNUSED.

ATF_TC ( rbt_remove_empty   ) 

ATF_TC_HEAD ( rbt_remove_empty  ,
tc   
)

Definition at line 897 of file rbt_test.c.

ATF_TC_BODY ( rbt_remove_empty  ,
tc   
)

Definition at line 902 of file rbt_test.c.

References build_name_from_str(), dns_rbtnode::data, delete_data(), dns__rbt_checkproperties(), dns_fixedname_name, dns_name_equal(), dns_rbt_create(), dns_rbt_deletenode(), dns_rbt_destroy(), dns_rbt_findnode(), DNS_RBTFIND_EMPTYDATA, dns_rbtnodechain_current(), dns_rbtnodechain_init(), dns_rbtnodechain_next(), dns_test_begin(), dns_test_end(), domain_names, domain_names_count, insert_helper(), ISC_FALSE, isc_mem_debugging, ISC_MEM_DEBUGRECORD, ISC_R_NOMORE, ISC_R_SUCCESS, ISC_TRUE, mctx, name, and UNUSED.

static void insert_nodes ( dns_rbt_t mytree,
char **  names,
size_t *  names_count,
isc_uint32_t  num_names 
) [static]

Definition at line 1128 of file rbt_test.c.

References build_name_from_str(), dns_fixedname_name, dns_rbt_addname(), isc_mem_get, isc_mem_strdup, ISC_R_SUCCESS, isc_random_get(), mctx, name, and namebuf.

Referenced by ATF_TC_BODY().

static void remove_nodes ( dns_rbt_t mytree,
char **  names,
size_t *  names_count,
isc_uint32_t  num_names 
) [static]

Definition at line 1171 of file rbt_test.c.

References build_name_from_str(), dns_fixedname_name, dns_rbt_deletename(), ISC_FALSE, isc_mem_free, ISC_R_SUCCESS, isc_random_get(), mctx, name, and UNUSED.

Referenced by ATF_TC_BODY().

static void check_tree ( dns_rbt_t mytree,
char **  names,
size_t  names_count 
) [static]

Definition at line 1204 of file rbt_test.c.

References dns__rbt_checkproperties(), dns__rbt_getheight(), dns_rbt_nodecount(), ISC_TRUE, and UNUSED.

Referenced by ATF_TC_BODY().

ATF_TC ( rbt_insert_and_remove   ) 

ATF_TC_HEAD ( rbt_insert_and_remove  ,
tc   
)

Definition at line 1223 of file rbt_test.c.

ATF_TC_BODY ( rbt_insert_and_remove  ,
tc   
)

Definition at line 1227 of file rbt_test.c.

References check_tree(), delete_data(), dns_rbt_create(), dns_rbt_destroy(), dns_test_begin(), dns_test_end(), insert_nodes(), isc_mem_debugging, ISC_MEM_DEBUGRECORD, isc_mem_free, ISC_R_SUCCESS, isc_random_get(), ISC_TRUE, mctx, remove_nodes(), and UNUSED.

ATF_TP_ADD_TCS ( tp   ) 

Definition at line 1311 of file rbt_test.c.


Variable Documentation

const char* const domain_names[] [static]

Initial value:

 {
    "c", "b", "a", "x.d.e.f", "z.d.e.f", "g.h", "i.g.h", "o.w.y.d.e.f",
    "j.z.d.e.f", "p.w.y.d.e.f", "q.w.y.d.e.f", "k.g.h"
}

Definition at line 89 of file rbt_test.c.

Referenced by ATF_TC_BODY(), check_test_data(), and test_context_setup().

const size_t domain_names_count [static]

Initial value:

 (sizeof(domain_names) /
                                          sizeof(domain_names[0]))

Definition at line 94 of file rbt_test.c.

Referenced by ATF_TC_BODY(), check_test_data(), and test_context_setup().

const int node_distances[] [static]

Initial value:

 {
    3, 1, 2, 2, 2, 3, 1, 2, 1, 1, 2, 2
}

Definition at line 100 of file rbt_test.c.

const char* const ordered_names[] [static]

Initial value:

 {
    "a", "b", "c", "d.e.f", "x.d.e.f", "w.y.d.e.f", "o.w.y.d.e.f",
    "p.w.y.d.e.f", "q.w.y.d.e.f", "z.d.e.f", "j.z.d.e.f",
    "g.h", "i.g.h", "k.g.h"}

Definition at line 125 of file rbt_test.c.

const size_t ordered_names_count [static]

Initial value:

 (sizeof(ordered_names) /
                                           sizeof(*ordered_names))

Definition at line 130 of file rbt_test.c.


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