Data Structures | Typedefs | Functions | Variables
unitmain.c File Reference

Unit test main program. More...

#include "config.h"
#include "sldns/rrdef.h"
#include "sldns/keyraw.h"
#include "util/log.h"
#include "testcode/unitmain.h"
#include "util/alloc.h"
#include "util/net_help.h"
#include "util/config_file.h"
#include "util/rtt.h"
#include "util/timehist.h"
#include "libunbound/unbound.h"
#include "services/cache/infra.h"
#include "util/random.h"
#include "respip/respip.h"
#include "services/localzone.h"
#include "util/data/packed_rrset.h"

Data Structures

struct  addr_action
 
struct  addr_data
 

Typedefs

typedef struct addr_action addr_action_t
 
typedef struct addr_data addr_data_t
 

Functions

static void alloc_test (void)
 test alloc code
 
static void net_test (void)
 test net code
 
static void config_memsize_test (void)
 test config_file: cfg_parse_memsize
 
static void config_tag_test (void)
 test config_file: test tag code
 
static void rtt_test (void)
 test RTT code
 
static struct infra_datainfra_lookup_host (struct infra_cache *infra, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *zone, size_t zonelen, int wr, time_t now, struct infra_key **k)
 
static void infra_test (void)
 test host cache
 
static void rnd_test (void)
 test randomness
 
static void verify_respip_set_actions (struct respip_set *set, addr_action_t actions[], int actions_len)
 Utility function that verifies that the respip set has actions as expected. More...
 
static void respip_conf_actions_test (void)
 Global respip actions test; apply raw config data and verify that all the nodes in the respip set, looked up by address, have expected actions.
 
static void respip_view_conf_actions_test (void)
 Per-view respip actions test; apply raw configuration with two views and verify that actions are as expected in respip sets of both views.
 
static void verify_rrset (struct respip_set *set, const char *ipstr, const char *rdatastr, size_t rdi, uint16_t type)
 find the respip address node in the specified tree (by address lookup) and verify type and address of the specified rdata (by index) in this node's rrset
 
static void cfg_insert_respip_data (struct config_str2list **respip_actions, struct config_str2list **respip_data)
 Populate raw respip redirect config data, used for both global and view-based respip redirect test case.
 
static void respip_conf_data_test (void)
 Test global respip redirect w/ data directives.
 
static void respip_view_conf_data_test (void)
 Test per-view respip redirect w/ data directives.
 
static void respip_test (void)
 respip unit tests
 
void unit_show_func (const char *file, const char *func)
 we are now testing this function
 
void unit_show_feature (const char *feature)
 we are testing this functionality
 
int main (int argc, char *argv[])
 Main unit test program. More...
 

Variables

int testcount = 0
 number of tests done
 
static addr_data_t config_response_ip_data []
 Dataset used to test redirect rrset initialization for both global and per-view respip redirect configuration. More...
 

Detailed Description

Unit test main program.

Calls all the other unit tests. Exits with code 1 on a failure. 0 if all unit tests are successful.

Function Documentation

◆ verify_respip_set_actions()

static void verify_respip_set_actions ( struct respip_set set,
addr_action_t  actions[],
int  actions_len 
)
static

Utility function that verifies that the respip set has actions as expected.

we have the node and the node has the correct action and has no data

References addr_tree_find(), rbtree_type::count, netblockstrtoaddr(), resp_addr::node, resp_addr_get_action(), resp_addr_get_rrset(), respip_set_get_tree(), and unit_assert.

◆ main()

int main ( int  argc,
char *  argv[] 
)

Main unit test program.

Setup, teardown and report errors.

Parameters
argcarg count.
argvarray of commandline arguments.
Returns
program failure if test fails.

References log_init().

Variable Documentation

◆ config_response_ip_data

addr_data_t config_response_ip_data[]
static
Initial value:
= {
{"192.0.1.0/24", "A 1.2.3.4"},
{"192.0.1.0/24", "A 11.12.13.14"},
{"192.0.2.0/24", "CNAME www.example.com."},
{"2001:db8:1::/48", "AAAA 2001:db8:1::2:1"},
}

Dataset used to test redirect rrset initialization for both global and per-view respip redirect configuration.