Blame tests/test_mem_leaks.sh

Packit 0b5880
#!/usr/bin/env sh
Packit 0b5880
Packit 0b5880
UNIT_TEST=./check_mem_leaks
Packit 0b5880
VALGRIND_LOG_FILE=${UNIT_TEST}.valgrind
Packit 0b5880
LEAK_MESSAGE="are definitely lost"
Packit 0b5880
Packit 0b5880
# This test runs valgrind against the check_mem_leaks unit test
Packit 0b5880
# program, looking for memory leaks. If any are found, "exit 1"
Packit 0b5880
# is invoked, and one must look through the resulting valgrind log
Packit 0b5880
# file for details on the leak.
Packit 0b5880
Packit 0b5880
rm -f ${VALGRIND_LOG_FILE}
Packit 0b5880
libtool --mode=execute valgrind --leak-check=full ${UNIT_TEST} 2>&1 | tee ${VALGRIND_LOG_FILE}
Packit 0b5880
Packit 0b5880
NUM_LEAKS=$(grep "${LEAK_MESSAGE}" ${VALGRIND_LOG_FILE} | wc -l)
Packit 0b5880
Packit 0b5880
if test ${NUM_LEAKS} -gt 0; then
Packit 0b5880
    echo "ERROR: ${NUM_LEAKS} memory leaks were detected by valgrind."
Packit 0b5880
    echo "       Look through ${VALGRIND_LOG_FILE} for details,"
Packit 0b5880
    echo "       searching for \"${LEAK_MESSAGE}\"."
Packit 0b5880
    exit 1
Packit 0b5880
else
Packit 0b5880
    echo "No memory leaks found"
Packit 0b5880
    exit 0
Packit 0b5880
fi