New tests for status.c
In order to increase test coverage for Tor, it would be advantageous to have some mechanism to decrease the friction involved in the mocking process a little bit. A number of macros are introduced for this purpose, and a new test suite is added that uses them to test
status.c (as a bit of a proof-of-concept) that gives 100% coverage.
The idea is to think of each test being executed in its own sub-namespace. Normally, we would create these sub-namespaces by appending the module and test names to our mock functions; the attached patch introduces macros to make this simpler. These macros will also declare variables in the current test namespace that can be used to track (manually) how many times a given mock was called. Finally, macros are introduced to make the declaration of the
struct testcase_t array simpler.
Some further refinements could be made (eg., having a nicer way to set up and tear down a test fixture), but this should prove a good starting point. The disadvantage of executing tests like this in their own namespace is some mocks will need to be duplicated if they are shared amongst different test cases, but it is more ideal for tests to not have dependencies on other test setups so that failures can be easily isolated.