UDP Redirect
Loading...
Searching...
No Matches
udp-redirect-test.c File Reference

Unit tests for udp-redirect.c helper functions. More...

#include "udp-redirect.c"
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
Include dependency graph for udp-redirect-test.c:

Macros

#define main
#define CHECK_DOUBLE(a, b, name)

Functions

static void check (int cond, const char *name)
static void test_parse_addr (void)
static void test_addr_tostring (void)
static void test_addr_port (void)
static void test_addr_len (void)
static void test_addr_is_unset (void)
static void test_addr_equal (void)
static void test_int_to_human (void)
static void test_settings_initialize (void)
static void test_statistics_initialize (void)
static void test_statistics_display (void)
static void test_socket_setup (void)
static void set_rcvtimeo (int fd)
static void test_cross_family_forwarding (void)

Variables

static int g_pass = 0
static int g_fail = 0

Detailed Description

Unit tests for udp-redirect.c helper functions.

Technique: rename main() in the source file via a preprocessor define before including it. This gives this translation unit full access to every static helper without requiring any changes to udp-redirect.c.

Build: gcc udp-redirect-test.c -o udp-redirect-test -Wall -O0 -lm Run: ./udp-redirect-test

Macro Definition Documentation

◆ CHECK_DOUBLE

#define CHECK_DOUBLE ( a,
b,
name )
Value:
check(fabs((double)(a) - (double)(b)) < 0.0001, (name))
static void check(int cond, const char *name)
Definition udp-redirect-test.c:27

◆ main

int main ( void)
Value:
udp_redirect_main

Function Documentation

◆ check()

void check ( int cond,
const char * name )
static
Here is the caller graph for this function:

◆ set_rcvtimeo()

void set_rcvtimeo ( int fd)
static
Here is the caller graph for this function:

◆ test_addr_equal()

void test_addr_equal ( void )
static
Here is the call graph for this function:

◆ test_addr_is_unset()

void test_addr_is_unset ( void )
static
Here is the call graph for this function:

◆ test_addr_len()

void test_addr_len ( void )
static
Here is the call graph for this function:

◆ test_addr_port()

void test_addr_port ( void )
static
Here is the call graph for this function:

◆ test_addr_tostring()

void test_addr_tostring ( void )
static
Here is the call graph for this function:

◆ test_cross_family_forwarding()

void test_cross_family_forwarding ( void )
static
Here is the call graph for this function:

◆ test_int_to_human()

void test_int_to_human ( void )
static
Here is the call graph for this function:

◆ test_parse_addr()

void test_parse_addr ( void )
static
Here is the call graph for this function:

◆ test_settings_initialize()

void test_settings_initialize ( void )
static
Here is the call graph for this function:

◆ test_socket_setup()

void test_socket_setup ( void )
static
Here is the call graph for this function:

◆ test_statistics_display()

void test_statistics_display ( void )
static
Here is the call graph for this function:

◆ test_statistics_initialize()

void test_statistics_initialize ( void )
static
Here is the call graph for this function:

Variable Documentation

◆ g_fail

int g_fail = 0
static

◆ g_pass

int g_pass = 0
static