[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Placing wrapped functions into a library
- Subject: Placing wrapped functions into a library
- From: Mark Syms <Mark.Syms@xxxxxxxxxx>
- Date: Fri, 14 Jul 2017 10:28:44 +0000
- To: "cmocka@xxxxxxxxxxxxxx" <cmocka@xxxxxxxxxxxxxx>
HI, I'm sure I'm missing something obvious here but I can't figure it out. I've got some cmocka unit tests for one module of the code I'm working on with a small set of wrapper functions to allow for isolation from the OS and environment. These are working fine and we get the results from the mocks that we expect. As part of extending the testing I realised that testing the other modules will need a similar set of wrapper functions and it therefore would make sense to move the wrappers to a static library that the different test groups all link to (having one test application per module so that it's all modular and easily understandable). But weirdly once I do this everything links OK however the tests fail because the mocks are not getting called and the underlying OS call is made directly. I can't understand this as the test code obviously managed to resolve the references into the wrappers otherwise compilation and link would fail. Am I missing something about how the "-Wl,--wrap" linker instruction works? I could move the source file for the wrappers to a central location and just reference it from all the test code (it is after all only test code) but I'd rather have the cleaner solution if at possible. Thanks, Mark.
|RE: Placing wrapped functions into a library||Mark Syms <Mark.Syms@xxxxxxxxxx>|