Skip to content

Commit

Permalink
Merge pull request #28805 from smuzaffar/unittest-valgrind-memleak
Browse files Browse the repository at this point in the history
New unit test to check if valgrind memory leaks functionality is working
  • Loading branch information
cmsbuild authored Jan 29, 2020
2 parents 2c19712 + 33f05f9 commit 71a8b5c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Utilities/ReleaseScripts/test/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<test name="TestSCRAM" command="run.sh"/>
<test name="TestValgrind" command="test-valgrind.sh">
<flags PRE_TEST="test-valgrind-memleak"/>
<use name="valgrind"/>
</test>
<bin name="test-valgrind-memleak" file="test-valgrind-memleak.cpp"/>
4 changes: 4 additions & 0 deletions Utilities/ReleaseScripts/test/test-valgrind-memleak.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
int main() {
int* a = new int[10];
return a[0];
}
18 changes: 18 additions & 0 deletions Utilities/ReleaseScripts/test/test-valgrind.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash -e

SCRIPT_NAME=$(basename $0)
TEST_NAME="test-valgrind-memleak"
valgrind --leak-check=full --undef-value-errors=no --error-limit=no \
${CMSSW_BASE}/test/${SCRAM_ARCH}/${TEST_NAME} > ${SCRIPT_NAME}.log 2>&1

cat ${SCRIPT_NAME}.log
echo ""
COUNT=$(grep 'definitely lost: [1-9][0-9]*' ${SCRIPT_NAME}.log | wc -l)
rm -f ${SCRIPT_NAME}.log

if [ $COUNT -eq 0 ] ; then
echo "ERROR: Valgrind was suppose to find memory leaks"
exit 1
else
echo "ALL OK"
fi

0 comments on commit 71a8b5c

Please sign in to comment.