OpenVPN
test_common.h File Reference
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <cmocka.h>
Include dependency graph for test_common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define HAVE_OLD_CMOCKA_API   1
#define LargestIntegralType   uintmax_t
#define CMockaValueData   LargestIntegralType
#define check_expected_uint   check_expected
#define expect_uint_value   expect_value
#define expect_check_data   expect_check
#define cast_ptr_to_cmocka_value(x)
#define assert_int_in_range(value, min, max)
#define assert_uint_in_range(value, min, max)

Functions

static void openvpn_unit_test_setup (void)
 Sets up the environment for unit tests like making both stderr and stdout non-buffered to avoid messages getting lost if the program exits early.
static void openvpn_test_get_srcdir_dir (char *buf, size_t bufsize, const char *filename)
 Helper function to get a file path from the unit test directory to open it or pass its path to another function.

Macro Definition Documentation

◆ assert_int_in_range

#define assert_int_in_range ( value,
min,
max )
Value:
assert_in_range((value), (min), (max))

Definition at line 51 of file test_common.h.

Referenced by send_control_channel_string_dowork().

◆ assert_uint_in_range

#define assert_uint_in_range ( value,
min,
max )
Value:
assert_in_range((value), (min), (max))

Definition at line 52 of file test_common.h.

◆ cast_ptr_to_cmocka_value

#define cast_ptr_to_cmocka_value ( x)
Value:
(x)

Definition at line 50 of file test_common.h.

Referenced by test_read_config().

◆ check_expected_uint

#define check_expected_uint   check_expected

Definition at line 47 of file test_common.h.

Referenced by add_option().

◆ CMockaValueData

#define CMockaValueData   LargestIntegralType

Definition at line 46 of file test_common.h.

Referenced by check_tokens().

◆ expect_check_data

#define expect_check_data   expect_check

Definition at line 49 of file test_common.h.

Referenced by test_read_config().

◆ expect_uint_value

#define expect_uint_value   expect_value

Definition at line 48 of file test_common.h.

Referenced by test_read_config().

◆ HAVE_OLD_CMOCKA_API

#define HAVE_OLD_CMOCKA_API   1

Definition at line 34 of file test_common.h.

◆ LargestIntegralType

#define LargestIntegralType   uintmax_t

Definition at line 43 of file test_common.h.

Function Documentation

◆ openvpn_test_get_srcdir_dir()

void openvpn_test_get_srcdir_dir ( char * buf,
size_t bufsize,
const char * filename )
inlinestatic

Helper function to get a file path from the unit test directory to open it or pass its path to another function.

This function will first look for an environment variable or if failing that, will fall back to a hardcoded value from compile time if compiled with CMake.

Parameters
bufbuffer holding the path to the file
bufsizesize of buf
filenamename of the filename to retrieve relative to the unit test source directory

Definition at line 86 of file test_common.h.

Referenced by test_get_user_pass_authfile_file(), test_get_user_pass_authfile_file_assertions(), and test_list().

◆ openvpn_unit_test_setup()

void openvpn_unit_test_setup ( void )
inlinestatic

Sets up the environment for unit tests like making both stderr and stdout non-buffered to avoid messages getting lost if the program exits early.

This has a openvpn prefix to avoid confusion with cmocka's unit_test_setup_* methods

Definition at line 63 of file test_common.h.

Referenced by main(), and wmain().