This commit is contained in:
djonker 2023-03-06 09:08:01 +01:00
parent 4fed32bbae
commit 5da295673c

35
test.sh
View File

@ -6,7 +6,7 @@
# By: houtworm <codam@houtworm.net> // \ \ __| | | \ \/ / #
# (| | )|_| |_| |> < #
# Created: 2023/02/20 12:46:46 by houtworm /'\_ _/`\__|\__,_/_/\_\ #
# Updated: 2023/02/25 03:51:43 by houtworm \___)=(___/ #
# Updated: 2023/03/06 09:04:17 by houtworm \___)=(___/ #
# #
# **************************************************************************** #
@ -17,6 +17,14 @@
PNAME=get_next_line.a
SLEEP=1
FAULTS=0
VALGRIND=0
which valgrind > /dev/null
if [ $? -eq 0 ]
then
VALGRIND=1
else
printf "\n\e[1;31mInstall Valgrind for extra Memory Checking\e[0;00m\n"
fi
HEADLOC=$(find ./ -name '*line.h' | grep -v tests)
mkdir -p tests/tmp
cp $HEADLOC tests/tmp/get_next_line.h
@ -60,7 +68,7 @@ getnextline()
cat tests/tmp/memorycheck | grep "leaked" > /dev/null
if [ $? -eq 1 ]
then
printf "\e[1;32mLeaks OK\e[0;00m\n"
printf "\e[1;32mNo Leaks Fsanitize\e[0;00m\n"
else
printf "\n\e[1;31mKO found Leaks \e[0;00m\n"
cat tests/tmp/memorycheck
@ -71,6 +79,29 @@ getnextline()
cat tests/tmp/memorycheck
FAULTS=$(($FAULTS+1))
fi
if [ $VALGRIND -eq 1 ]
then
gcc -o tests/tmp/binary ${SRCPATH}$2 get_next_line.a 2> /dev/null
valgrind --leak-check=full ./tests/tmp/binary 2> tests/tmp/memorycheck > /dev/null
cat tests/tmp/memorycheck | grep indirectly | grep "[123456789] bytes" > /dev/null
if [ $? -eq 0 ]
then
printf "\n\e[1;31mLeaks Valgrind $1 $2\e[0;00m\n"
cat tests/tmp/memorycheck
FAULTS=$(($FAULTS+1))
CURFUNERR=1
else
printf "\e[1;32mNo Leaks Valgrind\e[0;00m\n"
fi
cat tests/tmp/memorycheck | grep definitely | grep "[123456789] bytes" > /dev/null
if [ $? -eq 0 ]
then
printf "\n\e[1;31mLeaks Valgrind $1 $2\e[0;00m\n"
cat tests/tmp/memorycheck
FAULTS=$(($FAULTS+1))
CURFUNERR=1
fi
fi
}
checkfile()