-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28805 from smuzaffar/unittest-valgrind-memleak
New unit test to check if valgrind memory leaks functionality is working
- Loading branch information
Showing
3 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
int main() { | ||
int* a = new int[10]; | ||
return a[0]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |