unbound 0.1
unitneg.c File Reference

Calls negative cache unit tests. More...

#include "config.h"
#include "util/log.h"
#include "util/net_help.h"
#include "util/data/packed_rrset.h"
#include "util/data/dname.h"
#include "testcode/unitmain.h"
#include "validator/val_neg.h"
#include "sldns/rrdef.h"

Functions

static void print_neg_cache (struct val_neg_cache *neg)
 debug printout of neg cache
static char * get_random_zone (void)
 get static pointer to random zone name
static void get_random_data (char **fromp, char **top, char *zname)
 get static pointer to random data names from and to
static void add_item (struct val_neg_cache *neg)
 add a random item
static void remove_item (struct val_neg_cache *neg)
 remove a random item
static size_t sumtrees_all (struct val_neg_cache *neg)
 sum up the zone trees
static size_t sumtrees_inuse (struct val_neg_cache *neg)
 sum up the zone trees, in_use only
static void check_lru (struct val_neg_cache *neg)
 check if lru is still valid
static int sum_subtree_inuse (struct val_neg_zone *zone, struct val_neg_data *data)
 sum up number of items inuse in subtree
static int sum_zone_subtree_inuse (struct val_neg_cache *neg, struct val_neg_zone *zone)
 sum up number of items inuse in subtree
static void check_data (struct val_neg_zone *zone, struct val_neg_data *data)
 check point in data tree
static void checkzonetree (struct val_neg_zone *zone)
 check if tree of data in zone is valid
static void check_zone_invariants (struct val_neg_cache *neg, struct val_neg_zone *zone)
 check if negative cache is still valid
static void check_neg_invariants (struct val_neg_cache *neg)
 check if negative cache is still valid
static void stress_test (struct val_neg_cache *neg)
 perform stress test on insert and delete in neg cache
void neg_test (void)
 unit test for negative cache functions

Variables

static int negverbose = 0
 verbose unit test for negative cache

Detailed Description

Calls negative cache unit tests.

Exits with code 1 on a failure.

Function Documentation

◆ print_neg_cache()

◆ get_random_zone()

char * get_random_zone ( void )
static

get static pointer to random zone name

References get_random_zone().

Referenced by add_item(), and get_random_zone().

◆ get_random_data()

void get_random_data ( char ** fromp,
char ** top,
char * zname )
static

get static pointer to random data names from and to

References get_random_data(), log_nametypeclass(), and negverbose.

Referenced by add_item(), and get_random_data().

◆ add_item()

◆ remove_item()

◆ sumtrees_all()

size_t sumtrees_all ( struct val_neg_cache * neg)
static

sum up the zone trees

References rbtree_type::count, RBTREE_FOR, sumtrees_all(), val_neg_cache::tree, and val_neg_zone::tree.

Referenced by check_lru(), and sumtrees_all().

◆ sumtrees_inuse()

size_t sumtrees_inuse ( struct val_neg_cache * neg)
static

◆ check_lru()

void check_lru ( struct val_neg_cache * neg)
static

◆ sum_subtree_inuse()

int sum_subtree_inuse ( struct val_neg_zone * zone,
struct val_neg_data * data )
static

◆ sum_zone_subtree_inuse()

int sum_zone_subtree_inuse ( struct val_neg_cache * neg,
struct val_neg_zone * zone )
static

◆ check_data()

◆ checkzonetree()

void checkzonetree ( struct val_neg_zone * zone)
static

check if tree of data in zone is valid

References check_data(), checkzonetree(), RBTREE_FOR, val_neg_zone::tree, and val_neg_data::zone.

Referenced by check_zone_invariants(), and checkzonetree().

◆ check_zone_invariants()

◆ check_neg_invariants()

◆ stress_test()

void stress_test ( struct val_neg_cache * neg)
static

perform stress test on insert and delete in neg cache

References add_item(), check_neg_invariants(), val_neg_cache::first, negverbose, remove_item(), stress_test(), and unit_assert.

Referenced by neg_test(), and stress_test().

◆ neg_test()

void neg_test ( void )

unit test for negative cache functions

References neg_cache_delete(), neg_test(), stress_test(), unit_assert, unit_show_feature(), and val_neg_create().

Referenced by main(), and neg_test().

Variable Documentation

◆ negverbose

int negverbose = 0
static

verbose unit test for negative cache

Referenced by add_item(), check_lru(), check_zone_invariants(), get_random_data(), remove_item(), and stress_test().