DatabaseGroup / tree-similarity

Library for tree similarity algorithms and queries.
MIT License
74 stars 14 forks source link

Some memcheck notes #33

Open mateuszpawlik opened 3 months ago

mateuszpawlik commented 3 months ago

I don't know what these notes are about so I put it in the issue :-) I found these in my local copy of the repo.

Memory checking using ctest

Basic setup

To quickly use memcheck with ctest, add include(CTest) instead of #enable_testing(). Then use ctest as usually but add -T memcheck option. This should execute each test with valgrind (I guess valgrind should be installed first).

When ctest -T memcheck executed, the following output is possible when memcheck finds problems. The valgrind details are in the log files.

...
-- Processing memory checking output:
62/62 MemCheck: #62: lgm_ub_lb_fill_gaps_test .......................................   Defects: 2
MemCheck log files can be found here: ( * corresponds to test number)
/home/mpawlik/Remote/tree-similarity/build/Testing/Temporary/MemoryChecker.*.log
Memory checking results:
Uninitialized Memory Read - 2
        Errors while running CTest

Ignoring tests for memcheck

In CmakeLists.txt corresponding to tests to be ignored add:

configure_file(
  CTestCustom.cmake
  ${CMAKE_BINARY_DIR}/CTestCustom.cmake
)

In file CTestCustom.cmake add tests to ignore when memcheck. I couldn't find a way to use regex here.

list(
  APPEND CTEST_CUSTOM_MEMCHECK_IGNORE
  ted_join_correctness_test_naivejoin_129
)

Then, when executing ctest, specified tests will be ignored.

Some test execution times

ctest 240 sec

ctest -R ted_join_correctness_test_ -T memcheck 105 sec

ctest -R ted_join_correctness_test_guhajoin 102 sec

ctest -T memcheck 1361 sec

ctest -R guha 107 sec