OpenVPN
Functions
test_common.h File Reference
#include <stdio.h>
#include <setjmp.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.

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

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

Referenced by test_get_user_pass_authfile_file(), 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 36 of file test_common.h.

Referenced by main().