2 * QuanDocs unit test mock injection
4 * For some of our unit tests, we will want to override some libc functions with mock versions.
5 * I could do this by playing games with object link order and using dlsym(RTLD_NEXT) to follow the chain.
7 * But, that gets a bit tricky. For example, consider mocking write(), but leaving printf(), which may
8 * well be implemented in a way that calls write(stdout, ...), unintercepted.
10 * Thus, I opt to use a compile-time #define to reroute only our explicit calls to the libc functions
11 * to their mock variants.
14 #ifndef __QD_UNITTEST_H__
15 #define __QD_UNITTEST_H__
18 # define read(fd, buf, count) qdMock_read(fd, buf, count)
19 # define write(fd, buf, count) qdMock_write(fd, buf, count)
20 #endif /* QD_UNITTEST */
22 #endif /* __QD_UNITTEST_H__ */