OpenVPN
Macros | Functions
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)   (x)
 

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.
 
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

◆ cast_ptr_to_cmocka_value

#define cast_ptr_to_cmocka_value (   x)    (x)

Definition at line 50 of file test_common.h.

◆ check_expected_uint

#define check_expected_uint   check_expected

Definition at line 47 of file test_common.h.

◆ CMockaValueData

#define CMockaValueData   LargestIntegralType

Definition at line 46 of file test_common.h.

◆ expect_check_data

#define expect_check_data   expect_check

Definition at line 49 of file test_common.h.

◆ expect_uint_value

#define expect_uint_value   expect_value

Definition at line 48 of file test_common.h.

◆ 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 
)

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 82 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()

static 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 61 of file test_common.h.

References mbedtls_compat_psa_crypto_init().

Referenced by main(), and wmain().