I am using the cmocka library to test the inline c code. According to the documentation, I use a prefix __wrap_to extract functions so that I can isolate my unit tests. However, as soon as I do this, all function calls will go to the wrapped function forever. How to re-enable a real function in certain circumstances so that I can test it or allow other functions to be used? It seems to me the only way is to use the global field as a switch to call a real function as follows:
int __wrap_my_function(void) {
if (g_disable_wrap_my_function) {
return __real_my_function();
}
}
Is this the right way to do this?
source
share