unbound 0.1
unittcpreuse.c File Reference

Tests the tcp_reuse functionality. More...

#include "config.h"
#include "testcode/unitmain.h"
#include "util/log.h"
#include "util/net_help.h"
#include "util/random.h"
#include "services/outside_network.h"

Macros

#define MAX_TCP_WAITING_NODES   5

Functions

static void tcpid_addmore (struct reuse_tcp *reuse, struct outside_network *outnet, unsigned int addnum)
 add number of new IDs to the reuse tree, randomly chosen
static void tcpid_fillup (struct reuse_tcp *reuse, struct outside_network *outnet)
 fill up the reuse ID tree and test assertions
static void tcpid_test (void)
 test TCP ID selection
static void check_tree_and_list (struct outside_network *outnet, int present)
 check that the tree has present number of nodes and the LRU is linked properly.
static int create_pending_tcp (struct outside_network *outnet)
 creates pending_tcp.
static void empty_tree (struct outside_network *outnet)
 empty the tcp_reuse tree and LRU list
static void check_removal (struct outside_network *outnet, int position, int total)
 check removal of the LRU element on the given position of total elements
static void check_snip (struct outside_network *outnet, int total)
 check snipping off the last element of the LRU with total elements
static void tcp_reuse_tree_list_test (void)
 test tcp_reuse tree and LRU list functions
static void check_waiting_tcp_list (struct outside_network *outnet, struct waiting_tcp *first, struct waiting_tcp *last, size_t total)
static void waiting_tcp_list_clear (struct outside_network *outnet)
 clear the tcp waiting list
static void check_waiting_tcp_removal (int is_pop, struct outside_network *outnet, struct waiting_tcp *store, size_t position, size_t total)
 check removal of the waiting_tcp element on the given position of total elements
static void waiting_tcp_list_test (void)
static void check_reuse_write_wait (struct reuse_tcp *reuse, struct waiting_tcp *first, struct waiting_tcp *last, size_t total)
static void reuse_write_wait_clear (struct reuse_tcp *reuse)
 clear the tcp waiting list
static void check_reuse_write_wait_removal (int is_pop, struct reuse_tcp *reuse, struct waiting_tcp *store, size_t position, size_t total)
 check removal of the reuse_write_wait element on the given position of total elements
static void reuse_write_wait_test (void)
static void shared_port_test_ifs (void)
static int pif_list_contains (struct shared_ports_if *shpif, int item)
 See if a port is on the shared_ports ports list.
static int pif_list_contains_items (struct shared_ports_if *shpif, int item1, int item2, int item3, int item4)
 See if a number of ports are on the shared_ports list.
static void shared_port_test_port (void)
void tcpreuse_test (void)
 unit test for tcp_reuse functions

Detailed Description

Tests the tcp_reuse functionality.

Function Documentation

◆ tcpid_addmore()

void tcpid_addmore ( struct reuse_tcp * reuse,
struct outside_network * outnet,
unsigned int addnum )
static

◆ tcpid_fillup()

void tcpid_fillup ( struct reuse_tcp * reuse,
struct outside_network * outnet )
static

fill up the reuse ID tree and test assertions

References waiting_tcp::outnet, rbtree_init(), reuse_del_readwait(), reuse_id_cmp(), tcpid_addmore(), tcpid_fillup(), and reuse_tcp::tree_by_id.

Referenced by tcpid_fillup(), and tcpid_test().

◆ tcpid_test()

◆ check_tree_and_list()

void check_tree_and_list ( struct outside_network * outnet,
int present )
static

◆ create_pending_tcp()

int create_pending_tcp ( struct outside_network * outnet)
static

◆ empty_tree()

◆ check_removal()

void check_removal ( struct outside_network * outnet,
int position,
int total )
static

◆ check_snip()

◆ tcp_reuse_tree_list_test()

◆ waiting_tcp_list_clear()

◆ check_waiting_tcp_removal()

void check_waiting_tcp_removal ( int is_pop,
struct outside_network * outnet,
struct waiting_tcp * store,
size_t position,
size_t total )
static

◆ reuse_write_wait_clear()

void reuse_write_wait_clear ( struct reuse_tcp * reuse)
static

◆ check_reuse_write_wait_removal()

void check_reuse_write_wait_removal ( int is_pop,
struct reuse_tcp * reuse,
struct waiting_tcp * store,
size_t position,
size_t total )
static

◆ pif_list_contains()

int pif_list_contains ( struct shared_ports_if * shpif,
int item )
static

◆ pif_list_contains_items()

int pif_list_contains_items ( struct shared_ports_if * shpif,
int item1,
int item2,
int item3,
int item4 )
static

See if a number of ports are on the shared_ports list.

References pif_list_contains(), and pif_list_contains_items().

Referenced by pif_list_contains_items().

◆ tcpreuse_test()

void tcpreuse_test ( void )

unit test for tcp_reuse functions

References tcp_reuse_tree_list_test(), tcpid_test(), tcpreuse_test(), and unit_show_feature().

Referenced by main(), and tcpreuse_test().