OpenVPN
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
cmocka.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  UnitTest
 
struct  GroupTest
 
struct  CMUnitTest
 
struct  SourceLocation
 
struct  CheckParameterEvent
 

Macros

#define __WORDSIZE   32
 
#define LargestIntegralType   unsigned long long int
 
#define LargestIntegralTypePrintfFormat   "0x%I64x"
 
#define cast_to_largest_integral_type(value)   ((LargestIntegralType)(value))
 
#define _UINTPTR_T
 
#define _UINTPTR_T_DEFINED
 
#define cast_to_pointer_integral_type(value)   ((uintptr_t)((size_t)(value)))
 
#define cast_ptr_to_largest_integral_type(value)   cast_to_largest_integral_type(cast_to_pointer_integral_type(value))
 
#define CMOCKA_PRINTF_ATTRIBUTE(a, b)
 
#define CMOCKA_DEPRECATED
 
#define mock()   _mock(__func__, __FILE__, __LINE__)
 
#define mock_type(type)   ((type) mock())
 
#define mock_ptr_type(type)   ((type) (uintptr_t) mock())
 
#define will_return(function, value)
 
#define will_return_count(function, value, count)
 
#define will_return_always(function, value)   will_return_count(function, (value), -1)
 
#define will_return_maybe(function, value)   will_return_count(function, (value), -2)
 
#define expect_check(function, parameter, check_function, check_data)
 
#define expect_in_set(function, parameter, value_array)   expect_in_set_count(function, parameter, value_array, 1)
 
#define expect_in_set_count(function, parameter, value_array, count)
 
#define expect_not_in_set(function, parameter, value_array)   expect_not_in_set_count(function, parameter, value_array, 1)
 
#define expect_not_in_set_count(function, parameter, value_array, count)
 
#define expect_in_range(function, parameter, minimum, maximum)   expect_in_range_count(function, parameter, minimum, maximum, 1)
 
#define expect_in_range_count(function, parameter, minimum, maximum, count)
 
#define expect_not_in_range(function, parameter, minimum, maximum)   expect_not_in_range_count(function, parameter, minimum, maximum, 1)
 
#define expect_not_in_range_count(function, parameter, minimum, maximum, count)
 
#define expect_value(function, parameter, value)   expect_value_count(function, parameter, value, 1)
 
#define expect_value_count(function, parameter, value, count)
 
#define expect_not_value(function, parameter, value)   expect_not_value_count(function, parameter, value, 1)
 
#define expect_not_value_count(function, parameter, value, count)
 
#define expect_string(function, parameter, string)   expect_string_count(function, parameter, string, 1)
 
#define expect_string_count(function, parameter, string, count)
 
#define expect_not_string(function, parameter, string)   expect_not_string_count(function, parameter, string, 1)
 
#define expect_not_string_count(function, parameter, string, count)
 
#define expect_memory(function, parameter, memory, size)   expect_memory_count(function, parameter, memory, size, 1)
 
#define expect_memory_count(function, parameter, memory, size, count)
 
#define expect_not_memory(function, parameter, memory, size)   expect_not_memory_count(function, parameter, memory, size, 1)
 
#define expect_not_memory_count(function, parameter, memory, size, count)
 
#define expect_any(function, parameter)   expect_any_count(function, parameter, 1)
 
#define expect_any_count(function, parameter, count)   _expect_any(#function, #parameter, __FILE__, __LINE__, count)
 
#define check_expected(parameter)
 
#define check_expected_ptr(parameter)
 
#define assert_true(c)
 
#define assert_false(c)
 
#define assert_return_code(rc, error)
 
#define assert_non_null(c)
 
#define assert_null(c)
 
#define assert_ptr_equal(a, b)
 
#define assert_ptr_not_equal(a, b)
 
#define assert_int_equal(a, b)
 
#define assert_int_not_equal(a, b)
 
#define assert_string_equal(a, b)
 
#define assert_string_not_equal(a, b)
 
#define assert_memory_equal(a, b, size)
 
#define assert_memory_not_equal(a, b, size)
 
#define assert_in_range(value, minimum, maximum)
 
#define assert_not_in_range(value, minimum, maximum)
 
#define assert_in_set(value, values, number_of_values)   _assert_in_set(value, values, number_of_values, __FILE__, __LINE__)
 
#define assert_not_in_set(value, values, number_of_values)   _assert_not_in_set(value, values, number_of_values, __FILE__, __LINE__)
 
#define function_called()   _function_called(__func__, __FILE__, __LINE__)
 
#define expect_function_calls(function, times)   _expect_function_call(#function, __FILE__, __LINE__, times)
 
#define expect_function_call(function)   _expect_function_call(#function, __FILE__, __LINE__, 1)
 
#define expect_function_call_any(function)   _expect_function_call(#function, __FILE__, __LINE__, -1)
 
#define ignore_function_calls(function)   _expect_function_call(#function, __FILE__, __LINE__, -2)
 
#define fail()   _fail(__FILE__, __LINE__)
 
#define skip()   _skip(__FILE__, __LINE__)
 
#define fail_msg(msg, ...)
 
#define run_test(f)   _run_test(#f, f, NULL, UNIT_TEST_FUNCTION_TYPE_TEST, NULL)
 
#define unit_test(f)   { #f, f, UNIT_TEST_FUNCTION_TYPE_TEST }
 Initializes a UnitTest structure. More...
 
#define _unit_test_setup(test, setup)   { #test "_" #setup, setup, UNIT_TEST_FUNCTION_TYPE_SETUP }
 
#define unit_test_setup(test, setup)
 Initializes a UnitTest structure with a setup function. More...
 
#define _unit_test_teardown(test, teardown)   { #test "_" #teardown, teardown, UNIT_TEST_FUNCTION_TYPE_TEARDOWN }
 
#define unit_test_teardown(test, teardown)
 Initializes a UnitTest structure with a teardown function. More...
 
#define group_test_setup(setup)   { "group_" #setup, setup, UNIT_TEST_FUNCTION_TYPE_GROUP_SETUP }
 Initializes a UnitTest structure for a group setup function. More...
 
#define group_test_teardown(teardown)   { "group_" #teardown, teardown, UNIT_TEST_FUNCTION_TYPE_GROUP_TEARDOWN }
 Initializes a UnitTest structure for a group teardown function. More...
 
#define unit_test_setup_teardown(test, setup, teardown)
 Initialize an array of UnitTest structures with a setup function for a test and a teardown function. More...
 
#define cmocka_unit_test(f)   { #f, f, NULL, NULL, NULL }
 Initializes a CMUnitTest structure. More...
 
#define cmocka_unit_test_setup(f, setup)   { #f, f, setup, NULL, NULL }
 Initializes a CMUnitTest structure with a setup function. More...
 
#define cmocka_unit_test_teardown(f, teardown)   { #f, f, NULL, teardown, NULL }
 Initializes a CMUnitTest structure with a teardown function. More...
 
#define cmocka_unit_test_setup_teardown(f, setup, teardown)   { #f, f, setup, teardown, NULL }
 Initialize an array of CMUnitTest structures with a setup function for a test and a teardown function. More...
 
#define cmocka_unit_test_prestate(f, state)   { #f, f, NULL, NULL, state }
 Initialize a CMUnitTest structure with given initial state. More...
 
#define cmocka_unit_test_prestate_setup_teardown(f, setup, teardown, state)   { #f, f, setup, teardown, state }
 Initialize a CMUnitTest structure with given initial state, setup and teardown function. More...
 
#define run_tests(tests)   _run_tests(tests, sizeof(tests) / sizeof(tests)[0])
 
#define run_group_tests(tests)   _run_group_tests(tests, sizeof(tests) / sizeof(tests)[0])
 
#define cmocka_run_group_tests(group_tests, group_setup, group_teardown)   _cmocka_run_group_tests(#group_tests, group_tests, sizeof(group_tests) / sizeof(group_tests)[0], group_setup, group_teardown)
 
#define cmocka_run_group_tests_name(group_name, group_tests, group_setup, group_teardown)   _cmocka_run_group_tests(group_name, group_tests, sizeof(group_tests) / sizeof(group_tests)[0], group_setup, group_teardown)
 
#define test_malloc(size)   _test_malloc(size, __FILE__, __LINE__)
 
#define test_calloc(num, size)   _test_calloc(num, size, __FILE__, __LINE__)
 
#define test_realloc(ptr, size)   _test_realloc(ptr, size, __FILE__, __LINE__)
 
#define test_free(ptr)   _test_free(ptr, __FILE__, __LINE__)
 
#define expect_assert_failure(function_call)
 

Typedefs

typedef unsigned int uintptr_t
 
typedef void(* UnitTestFunction) (void **state)
 
typedef int(* CheckParameterValue) (const LargestIntegralType value, const LargestIntegralType check_value_data)
 
typedef enum UnitTestFunctionType UnitTestFunctionType
 
typedef struct UnitTest UnitTest
 
typedef struct GroupTest GroupTest
 
typedef void(* CMUnitTestFunction) (void **state)
 
typedef int(* CMFixtureFunction) (void **state)
 
typedef struct SourceLocation SourceLocation
 
typedef struct CheckParameterEvent CheckParameterEvent
 

Enumerations

enum  UnitTestFunctionType {
  UNIT_TEST_FUNCTION_TYPE_TEST = 0, UNIT_TEST_FUNCTION_TYPE_SETUP, UNIT_TEST_FUNCTION_TYPE_TEARDOWN, UNIT_TEST_FUNCTION_TYPE_GROUP_SETUP,
  UNIT_TEST_FUNCTION_TYPE_GROUP_TEARDOWN
}
 
enum  cm_message_output { CM_OUTPUT_STDOUT, CM_OUTPUT_SUBUNIT, CM_OUTPUT_TAP, CM_OUTPUT_XML }
 

Functions

static void _unit_test_dummy (void **state)
 
void mock_assert (const int result, const char *const expression, const char *const file, const int line)
 Function to replace assert(3) in tested code. More...
 
LargestIntegralType _mock (const char *const function, const char *const file, const int line)
 
void _expect_function_call (const char *const function_name, const char *const file, const int line, const int count)
 
void _function_called (const char *const function, const char *const file, const int line)
 
void _expect_check (const char *const function, const char *const parameter, const char *const file, const int line, const CheckParameterValue check_function, const LargestIntegralType check_data, CheckParameterEvent *const event, const int count)
 
void _expect_in_set (const char *const function, const char *const parameter, const char *const file, const int line, const LargestIntegralType values[], const size_t number_of_values, const int count)
 
void _expect_not_in_set (const char *const function, const char *const parameter, const char *const file, const int line, const LargestIntegralType values[], const size_t number_of_values, const int count)
 
void _expect_in_range (const char *const function, const char *const parameter, const char *const file, const int line, const LargestIntegralType minimum, const LargestIntegralType maximum, const int count)
 
void _expect_not_in_range (const char *const function, const char *const parameter, const char *const file, const int line, const LargestIntegralType minimum, const LargestIntegralType maximum, const int count)
 
void _expect_value (const char *const function, const char *const parameter, const char *const file, const int line, const LargestIntegralType value, const int count)
 
void _expect_not_value (const char *const function, const char *const parameter, const char *const file, const int line, const LargestIntegralType value, const int count)
 
void _expect_string (const char *const function, const char *const parameter, const char *const file, const int line, const char *string, const int count)
 
void _expect_not_string (const char *const function, const char *const parameter, const char *const file, const int line, const char *string, const int count)
 
void _expect_memory (const char *const function, const char *const parameter, const char *const file, const int line, const void *const memory, const size_t size, const int count)
 
void _expect_not_memory (const char *const function, const char *const parameter, const char *const file, const int line, const void *const memory, const size_t size, const int count)
 
void _expect_any (const char *const function, const char *const parameter, const char *const file, const int line, const int count)
 
void _check_expected (const char *const function_name, const char *const parameter_name, const char *file, const int line, const LargestIntegralType value)
 
void _will_return (const char *const function_name, const char *const file, const int line, const LargestIntegralType value, const int count)
 
void _assert_true (const LargestIntegralType result, const char *const expression, const char *const file, const int line)
 
void _assert_return_code (const LargestIntegralType result, size_t rlen, const LargestIntegralType error, const char *const expression, const char *const file, const int line)
 
void _assert_int_equal (const LargestIntegralType a, const LargestIntegralType b, const char *const file, const int line)
 
void _assert_int_not_equal (const LargestIntegralType a, const LargestIntegralType b, const char *const file, const int line)
 
void _assert_string_equal (const char *const a, const char *const b, const char *const file, const int line)
 
void _assert_string_not_equal (const char *const a, const char *const b, const char *file, const int line)
 
void _assert_memory_equal (const void *const a, const void *const b, const size_t size, const char *const file, const int line)
 
void _assert_memory_not_equal (const void *const a, const void *const b, const size_t size, const char *const file, const int line)
 
void _assert_in_range (const LargestIntegralType value, const LargestIntegralType minimum, const LargestIntegralType maximum, const char *const file, const int line)
 
void _assert_not_in_range (const LargestIntegralType value, const LargestIntegralType minimum, const LargestIntegralType maximum, const char *const file, const int line)
 
void _assert_in_set (const LargestIntegralType value, const LargestIntegralType values[], const size_t number_of_values, const char *const file, const int line)
 
void _assert_not_in_set (const LargestIntegralType value, const LargestIntegralType values[], const size_t number_of_values, const char *const file, const int line)
 
void * _test_malloc (const size_t size, const char *file, const int line)
 
void * _test_realloc (void *ptr, const size_t size, const char *file, const int line)
 
void * _test_calloc (const size_t number_of_elements, const size_t size, const char *file, const int line)
 
void _test_free (void *const ptr, const char *file, const int line)
 
void _fail (const char *const file, const int line)
 
void _skip (const char *const file, const int line)
 
int _run_test (const char *const function_name, const UnitTestFunction Function, void **const volatile state, const UnitTestFunctionType function_type, const void *const heap_check_point)
 
CMOCKA_DEPRECATED int _run_tests (const UnitTest *const tests, const size_t number_of_tests)
 
CMOCKA_DEPRECATED int _run_group_tests (const UnitTest *const tests, const size_t number_of_tests)
 
int _cmocka_run_group_tests (const char *group_name, const struct CMUnitTest *const tests, const size_t num_tests, CMFixtureFunction group_setup, CMFixtureFunction group_teardown)
 
void print_message (const char *const format,...) CMOCKA_PRINTF_ATTRIBUTE(1
 
void void print_error (const char *const format,...) CMOCKA_PRINTF_ATTRIBUTE(1
 
void void void vprint_message (const char *const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1
 
void void void void vprint_error (const char *const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1
 
void cmocka_set_message_output (enum cm_message_output output)
 Function to set the output format for a test. More...
 

Variables

int global_expecting_assert
 
jmp_buf global_expect_assert_env
 
const char * global_last_failed_assert