ctest_memcheck: generate DynamicAnalysis-Test.xml as well

This is useful so that memcheck results also show up as test results on
CDash. It will be submitted with the other `MemCheck` parts.

Fixes: #22190
This commit is contained in:
Ben Boeckel 2021-08-28 15:12:30 -04:00
parent 9c8e25c5fd
commit ce44c2cec3
8 changed files with 50 additions and 1 deletions

View File

@ -30,7 +30,8 @@ The options are:
Build = ctest_build results, in Build.xml
Test = ctest_test results, in Test.xml
Coverage = ctest_coverage results, in Coverage.xml
MemCheck = ctest_memcheck results, in DynamicAnalysis.xml
MemCheck = ctest_memcheck results, in DynamicAnalysis.xml and
DynamicAnalysis-Test.xml
Notes = Files listed by CTEST_NOTES_FILES, in Notes.xml
ExtraFiles = Files listed by CTEST_EXTRA_SUBMIT_FILES
Upload = Files prepared for upload by ctest_upload(), in Upload.xml

View File

@ -0,0 +1,6 @@
ctest_memcheck-generate-test.xml
--------------------------------
* The :command:`ctest_memcheck` command now also generates a
`DynamicAnalysis-Test.xml` file which may be used to submit test results to
CDash.

View File

@ -804,6 +804,7 @@ int cmCTestSubmitHandler::ProcessHandler()
}
}
this->CTest->AddIfExists(cmCTest::PartMemCheck, "DynamicAnalysis.xml");
this->CTest->AddIfExists(cmCTest::PartMemCheck, "DynamicAnalysis-Test.xml");
this->CTest->AddIfExists(cmCTest::PartMemCheck, "Purify.xml");
this->CTest->AddIfExists(cmCTest::PartNotes, "Notes.xml");
this->CTest->AddIfExists(cmCTest::PartUpload, "Upload.xml");

View File

@ -705,6 +705,21 @@ bool cmCTestTestHandler::GenerateXML()
this->GenerateCTestXML(xml);
}
if (this->MemCheck) {
cmGeneratedFileStream xmlfile;
if (!this->StartResultingXML(cmCTest::PartTest, "DynamicAnalysis-Test",
xmlfile)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot create testing XML file" << std::endl);
this->LogFile = nullptr;
return false;
}
cmXMLWriter xml(xmlfile);
// Explicitly call this class' `GenerateCTestXML` method to make `Test.xml`
// as well.
this->cmCTestTestHandler::GenerateCTestXML(xml);
}
return true;
}

View File

@ -0,0 +1,10 @@
function (find_xml_file name)
file(GLOB test_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/${name}.xml")
if (NOT test_xml_file)
message(FATAL_ERROR
"${name}.xml not created.")
endif ()
endfunction ()
find_xml_file(DynamicAnalysis)
find_xml_file(DynamicAnalysis-Test)

View File

@ -0,0 +1 @@
Cannot find memory tester output file: .*/Tests/RunCMake/ctest_memcheck/ExpectedOutputs-build/Testing/Temporary/MemoryChecker.1.log\.\*

View File

@ -0,0 +1,2 @@
Memory checking results:
left shift of negative value -256 - 1

View File

@ -94,6 +94,19 @@ run_mc_test(DummyUndefinedBehaviorSanitizer "" -DMEMCHECK_TYPE=UndefinedBehavior
unset(CMAKELISTS_EXTRA_CODE)
unset(CTEST_EXTRA_CODE)
#-----------------------------------------------------------------------------
# add output test
set(CTEST_EXTRA_CODE
"set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS \"simulate_sanitizer=1\")
")
set(CMAKELISTS_EXTRA_CODE
"add_test(NAME TestSan COMMAND \"\${CMAKE_COMMAND}\"
-P \"${RunCMake_SOURCE_DIR}/testUndefinedBehaviorSanitizer.cmake\")
")
run_mc_test(ExpectedOutputs "" -DMEMCHECK_TYPE=UndefinedBehaviorSanitizer)
unset(CMAKELISTS_EXTRA_CODE)
unset(CTEST_EXTRA_CODE)
#-----------------------------------------------------------------------------
set(CTEST_EXTRA_CODE "string(REPLACE \" \" \"\\\\ \" PRE_POST_COMMAND \"\${CTEST_MEMORYCHECK_COMMAND}\")