Is it good practice to use the weak attribute in production code so that for test code one can override functions?
I don't know if it is good practice, but there are ways to override functions in test code that do not interfere with production code:
LD_PRELOAD
__weak
in debug mode and to nothing in production mode.