OpenVPN
|
Memory leaks, buffer overflows and underflows can be checked using cmocka. More...
Macros | |
#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__) |
Memory leaks, buffer overflows and underflows can be checked using cmocka.
To test for memory leaks, buffer overflows and underflows a module being tested by cmocka should replace calls to malloc(), calloc() and free() to test_malloc(), test_calloc() and test_free() respectively. Each time a block is deallocated using test_free() it is checked for corruption, if a corrupt block is found a test failure is signalled. All blocks allocated using the test_*() allocation functions are tracked by the cmocka library. When a test completes if any allocated blocks (memory leaks) remain they are reported and a test failure is signalled.
For simplicity cmocka currently executes all tests in one process. Therefore all test cases in a test application share a single address space which means memory corruption from a single test case could potentially cause the test application to exit prematurely.
#define test_calloc | ( | num, | |
size | |||
) | _test_calloc(num, size, __FILE__, __LINE__) |
#define test_free | ( | ptr | ) | _test_free(ptr, __FILE__, __LINE__) |
Definition at line 1920 of file cmocka.h.
Referenced by destroy_key_values(), test_perform_operation(), torture_test_malloc(), and torture_test_realloc().
#define test_malloc | ( | size | ) | _test_malloc(size, __FILE__, __LINE__) |
Definition at line 1872 of file cmocka.h.
Referenced by create_key_values(), torture_test_malloc(), torture_test_realloc(), and torture_test_realloc_set0().
#define test_realloc | ( | ptr, | |
size | |||
) | _test_realloc(ptr, size, __FILE__, __LINE__) |
Definition at line 1907 of file cmocka.h.
Referenced by torture_test_realloc(), and torture_test_realloc_set0().