Crinit -- Configurable Rootfs Init
unit_test.h File Reference

(2023-10-16, commit: 49337e0)

Header for common definitions/includes specifically for cmocka unit tests. More...

#include <setjmp.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <cmocka.h>
Include dependency graph for unit_test.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ARRAY_SIZE(array)   (sizeof(array) / sizeof(*(array)))
 
#define cast_to_largest_integral_type(value)   cast_to_uintmax_type(value)
 
#define check_expected_dynamic(parameter_string, value)    _check_expected(__func__, parameter_string, __FILE__, __LINE__, cast_to_largest_integral_type(value))
 
#define will_set_parameter(METHOD, PARAM_NAME, VALUE)   will_return(METHOD, VALUE)
 

Detailed Description

Header for common definitions/includes specifically for cmocka unit tests.

Macro Definition Documentation

◆ ARRAY_SIZE

#define ARRAY_SIZE (   array)    (sizeof(array) / sizeof(*(array)))

◆ cast_to_largest_integral_type

#define cast_to_largest_integral_type (   value)    cast_to_uintmax_type(value)

◆ check_expected_dynamic

#define check_expected_dynamic (   parameter_string,
  value 
)     _check_expected(__func__, parameter_string, __FILE__, __LINE__, cast_to_largest_integral_type(value))

Determine whether a function parameter is correct.

This ensures the next value queued by one of the expect_*() macros matches the specified value. In contrast to check_expected(), this function takes the parameter name as a string that can be created at runtime.

This function needs to be called in the mock object.

◆ will_set_parameter

#define will_set_parameter (   METHOD,
  PARAM_NAME,
  VALUE 
)    will_return(METHOD, VALUE)

CMocka macro to be used to mock return paramters.