I'm trying to write unit tests for a C lib I've made.
To do so I'm using the lib criterion
.
I would like to use valgrind to detect memory leaks and context error, when I run make test
it generate a unit_test.o
file that I can run throw valgrind and here is the result :
test: clean $(TEST_OBJ)
$(CC) -o ${TEST_NAME} ${SRC} $(TEST_SRC) --coverage -lcriterion
./${TEST_NAME}
As you can see, I have 0 leaks and 0 context error which is not true as the tested code contains both. If I run the same code in the main
function It will detect both leaks and contexts.
It looks like criterion execute the unit_tests in a kind of "safe" context and free all the memory itself.
My question is how can I test leaks and contexts from my criterion unit tests ?
Or, what are the alternative to test it ?