tim-balloon / TIMflight

Flight MCP repo
0 stars 0 forks source link

Compile a unit test against mcp code #22

Closed evanmayer closed 2 years ago

evanmayer commented 2 years ago

Task

We need to create and compile a unit test against a subset of mcp code to start getting some segments of it under test.

Acceptance

A tests dir is created in a module's directory, with a CMocka unit test that is conditionally compiled on the -DENABLE_TESTING=ON cmake flag. Any tests pass, it can even be one test.

Details

In order to compile and test some segment of code without compiling the entire mcp executable, we need to compile that segment as a library. In order to do that, the segment's dependencies need to be rooted out and specified to the linker. If the dependencies aren't able to be linked to, they will also need to be made libraries, or header include paths specified.

This is harder than it sounds due to the monolithic CMake structure of the mcp build target. This will be a lot of CMake work. The result may be messy, and that is ok - we need to expose dependency webs explicitly before we can begin untangling them.

Effectively, we are creating a linker seam here where there was none because of the CMake build structure. Once dependencies are resolved by the linker, a unit test can mock them out by linking to dummy versions as needed.