Skip to content

CTest: Save sanitizer output files after test execution

paweldac requested to merge paweldac/cmake:sanitizers_save_memcheck_files into master

Prior to this change if any MemCheck fails during ctest -D ExperimentalMemCheck in output user gets following message:

`The following tests FAILED:
          6 - Test.MemoryIssue (Failed)
-- Processing memory checking output:
6/8 MemCheck: #6: Test.MemoryIssue ...  Defects: 1
MemCheck log files can be found here: (<#> corresponds to test number)
${project_dir}/build/Testing/Temporary/MemoryChecker.<#>.log
Memory checking results:
Direct leak - 1
        Errors while running CTest

When MEMORYCHECK_TYPE is set to [Thread|Address|Leak|Memory|UndefinedBehavior]Sanitizer there are no output files in ${project_dir}/build/Testing/Temporary/MemoryChecker.<#>.log

This happens, because during MemCheckPostProcess phase MemChecks output file, when there is pid in its filename, is deleted.

In this MR I change MemCheckPostProcess behavior. In this proposal when output filename contains pid, then file is renamed and pid is removed from filename.

Sanitizers log files were affected by previous implementation, because pid is required for them to work. this->LogWithPID is set to true only in case of Sanitizers (:504/:510:/...). All other MEMORYCHECK_TYPE options are using initialized value - false (:125/:131/).

In this change MemCheckPostProcess renames output files containing pid in their files names to match file path from message presented to user - ${project_dir}/build/Testing/Temporary/MemoryChecker.<#>.log

Fixes: #21155 (closed)

Edited by paweldac

Merge request reports