OpenVPN
test_route.c File Reference
#include "syshead.h"
#include "test_common.h"
#include "route.h"
#include "networking.h"
#include "test_route.h"
Include dependency graph for test_route.c:

Go to the source code of this file.

Functions

struct argv argv_new (void)
 Allocates a new struct argv and ensures it is initialised.
void argv_free (struct argv *a)
 Frees all memory allocations allocated by the struct argv related functions.
bool get_ipv6_addr (const char *prefix_str, struct in6_addr *network, unsigned int *netbits, msglvl_t msglevel)
 Translate an IPv6 addr or hostname from string form to in6_addr.
in_addr_t getaddr (unsigned int flags, const char *hostname, int resolve_retry, bool *succeeded, struct signal_info *sig_info)
 Translate an IPv4 addr or hostname from string form to in_addr_t.
int openvpn_getaddrinfo (unsigned int flags, const char *hostname, const char *servname, int resolve_retry_seconds, struct signal_info *sig_info, int ai_family, struct addrinfo **res)
int signal_reset (struct signal_info *si, int signum)
 Clear the signal if its current value equals signum.
static void test_is_special_addr (void **state)
static void test_netmask_to_netbits (void **state)
static void test_netmask_to_netbits2 (void **state)
static void assert_clear_host_bits (const char *addr, unsigned int netbits, const char *expected)
static void test_route_ipv6_clear_host_bits (void **state)
int route_tests (void)
 Runs the route.c unit tests, returns the number of failures.

Variables

struct signal_info siginfo_static
static const struct CMUnitTest route_test_list []

Function Documentation

◆ argv_free()

void argv_free ( struct argv * a)

Frees all memory allocations allocated by the struct argv related functions.

Parameters
aValid pointer to a struct argv to release memory from

Definition at line 49 of file test_route.c.

◆ argv_new()

struct argv argv_new ( void )

Allocates a new struct argv and ensures it is initialised.

Note that it does not return a pointer, but a struct argv directly.

Returns
Returns an initialised and empty struct argv.

Definition at line 41 of file test_route.c.

References argv_new().

◆ assert_clear_host_bits()

void assert_clear_host_bits ( const char * addr,
unsigned int netbits,
const char * expected )
static

Definition at line 139 of file test_route.c.

References CLEAR, r6, and route_ipv6_clear_host_bits().

Referenced by test_route_ipv6_clear_host_bits().

◆ get_ipv6_addr()

bool get_ipv6_addr ( const char * prefix_str,
struct in6_addr * network,
unsigned int * netbits,
msglvl_t msglevel )

Translate an IPv6 addr or hostname from string form to in6_addr.

Definition at line 55 of file test_route.c.

Referenced by ipv6_addr_safe_hexplusbits().

◆ getaddr()

in_addr_t getaddr ( unsigned int flags,
const char * hostname,
int resolve_retry_seconds,
bool * succeeded,
struct signal_info * sig_info )

Translate an IPv4 addr or hostname from string form to in_addr_t.

In case of resolve error, it will try again for resolve_retry_seconds seconds.

Definition at line 63 of file test_route.c.

◆ openvpn_getaddrinfo()

int openvpn_getaddrinfo ( unsigned int flags,
const char * hostname,
const char * servname,
int resolve_retry_seconds,
struct signal_info * sig_info,
int ai_family,
struct addrinfo ** res )

Definition at line 71 of file test_route.c.

◆ route_tests()

int route_tests ( void )

Runs the route.c unit tests, returns the number of failures.

Definition at line 177 of file test_route.c.

References openvpn_unit_test_setup(), and route_test_list.

Referenced by main().

◆ signal_reset()

int signal_reset ( struct signal_info * si,
int signum )

Clear the signal if its current value equals signum.

If signum is zero the signal is cleared independent of its current value.

Returns
the current value of the signal.

If signum is zero the signal is cleared independent of its current value. Returns the current value of the signal.

Definition at line 82 of file test_route.c.

◆ test_is_special_addr()

void test_is_special_addr ( void ** state)
static

Definition at line 89 of file test_route.c.

References is_special_addr().

◆ test_netmask_to_netbits()

void test_netmask_to_netbits ( void ** state)
static

Definition at line 101 of file test_route.c.

References netmask_to_netbits().

◆ test_netmask_to_netbits2()

void test_netmask_to_netbits2 ( void ** state)
static

Definition at line 126 of file test_route.c.

References netmask_to_netbits2().

◆ test_route_ipv6_clear_host_bits()

void test_route_ipv6_clear_host_bits ( void ** state)
static

Definition at line 154 of file test_route.c.

References assert_clear_host_bits().

Variable Documentation

◆ route_test_list

const struct CMUnitTest route_test_list[]
static
Initial value:
= {
cmocka_unit_test(test_is_special_addr),
cmocka_unit_test(test_netmask_to_netbits),
cmocka_unit_test(test_netmask_to_netbits2),
}
static void test_route_ipv6_clear_host_bits(void **state)
Definition test_route.c:154
static void test_netmask_to_netbits(void **state)
Definition test_route.c:101
static void test_netmask_to_netbits2(void **state)
Definition test_route.c:126
static void test_is_special_addr(void **state)
Definition test_route.c:89

Definition at line 169 of file test_route.c.

Referenced by route_tests().

◆ siginfo_static

struct signal_info siginfo_static

Definition at line 79 of file test_route.c.