I am building unit tests with CMocka. My function char some_func(some_enum e)
maps valid values of e
to a char
. It uses assert
to check e
is valid, which by definition calls abort
if not.
Mocking abort
is proving to be hard. Following this example and building a function ...
static volatile abort_calls = 0;
void
__wrap_abort(void)
{
fprintf(stderr, "Call to __wrap_abort()\n");
abort_calls++;
}
static void
test_some_func(void **state)
{
some_func( (some_enum)99);
assert_int_equal(1, abort_calls);
}
.. that when compiled with -Wl,--wrap=abort
makes no complaints. However, when executed it does not call __wrap_abort
.
Is what I'm attempting even possible?