updatetempdirtester

This commit is contained in:
djonker 2023-03-11 08:02:58 +01:00
parent 7f611435aa
commit 37bc3c2431

58
test.sh
View File

@ -6,7 +6,7 @@
# By: houtworm <codam@houtworm.net> // \ \ __| | | \ \/ / # # By: houtworm <codam@houtworm.net> // \ \ __| | | \ \/ / #
# (| | )|_| |_| |> < # # (| | )|_| |_| |> < #
# Created: 2023/02/20 12:46:46 by houtworm /'\_ _/`\__|\__,_/_/\_\ # # Created: 2023/02/20 12:46:46 by houtworm /'\_ _/`\__|\__,_/_/\_\ #
# Updated: 2023/03/07 19:06:23 by houtworm \___)=(___/ # # Updated: 2023/03/11 08:02:41 by houtworm \___)=(___/ #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -26,8 +26,8 @@ else
printf "\n\e[1;31mInstall Valgrind for extra Memory Checking\e[0;00m\n" printf "\n\e[1;31mInstall Valgrind for extra Memory Checking\e[0;00m\n"
fi fi
HEADLOC=$(find ./ -name '*line.h' | grep -v tests | grep -v ccls) HEADLOC=$(find ./ -name '*line.h' | grep -v tests | grep -v ccls)
mkdir -p tests/tmp mkdir -p tmp
cp $HEADLOC tests/tmp/get_next_line.h cp $HEADLOC tmp/get_next_line.h
if [ $1 == "old" ] if [ $1 == "old" ]
then then
SRCPATH="tests/src/old/" SRCPATH="tests/src/old/"
@ -38,7 +38,7 @@ then
FILPATH="tests/files/new/" FILPATH="tests/files/new/"
else else
printf "\e[1;31mPlease run the tester as follows\n./test.sh [VERSION] [SLEEPTIME]\nold returns an int while new returns the line\nexamples:\n./test.sh old\n./test.sh new\n./test.sh old 5\e[0;00m\n" printf "\e[1;31mPlease run the tester as follows\n./test.sh [VERSION] [SLEEPTIME]\nold returns an int while new returns the line\nexamples:\n./test.sh old\n./test.sh new\n./test.sh old 5\e[0;00m\n"
rm -rf tests/tmp rm -rf tmp
exit 1 exit 1
fi fi
if [ $2 ] if [ $2 ]
@ -50,9 +50,9 @@ fi
getnextline() getnextline()
{ {
gcc -D BUFFER_SIZE=$1 -o tests/tmp/binary ${SRCPATH}$2 get_next_line.a gcc -D BUFFER_SIZE=$1 -o tmp/binary ${SRCPATH}$2 get_next_line.a
./tests/tmp/binary > tests/tmp/output ./tmp/binary > tmp/output
diff ${FILPATH}$3 tests/tmp/output > /dev/null diff ${FILPATH}$3 tmp/output > /dev/null
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
printf "\e[1;32mOutput OK\e[0;00m\n" printf "\e[1;32mOutput OK\e[0;00m\n"
@ -60,44 +60,44 @@ getnextline()
printf "\e[1;31mOutput is wrong\e[0;00m\n" printf "\e[1;31mOutput is wrong\e[0;00m\n"
FAULTS=$(($FAULTS+1)) FAULTS=$(($FAULTS+1))
fi fi
gcc -g -fsanitize=address -D BUFFER_SIZE=$1 -o tests/tmp/binary ${SRCPATH}$2 get_next_line.a gcc -g -fsanitize=address -D BUFFER_SIZE=$1 -o tmp/binary ${SRCPATH}$2 get_next_line.a
./tests/tmp/binary > tests/tmp/output 2>tests/tmp/memorycheck ./tmp/binary > tmp/output 2>tmp/memorycheck
diff ${FILPATH}$3 tests/tmp/output > /dev/null diff ${FILPATH}$3 tmp/output > /dev/null
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
cat tests/tmp/memorycheck | grep "leaked" > /dev/null cat tmp/memorycheck | grep "leaked" > /dev/null
if [ $? -eq 1 ] if [ $? -eq 1 ]
then then
printf "\e[1;32mNo Leaks Fsanitize\e[0;00m\n" printf "\e[1;32mNo Leaks Fsanitize\e[0;00m\n"
else else
printf "\n\e[1;31mKO found Leaks \e[0;00m\n" printf "\n\e[1;31mKO found Leaks \e[0;00m\n"
cat tests/tmp/memorycheck cat tmp/memorycheck
FAULTS=$(($FAULTS+1)) FAULTS=$(($FAULTS+1))
fi fi
else else
printf "\e[1;31mKO with fsanitize\e[0;00m\n" printf "\e[1;31mKO with fsanitize\e[0;00m\n"
cat tests/tmp/memorycheck cat tmp/memorycheck
FAULTS=$(($FAULTS+1)) FAULTS=$(($FAULTS+1))
fi fi
if [ $VALGRIND -eq 1 ] if [ $VALGRIND -eq 1 ]
then then
gcc -o tests/tmp/binary ${SRCPATH}$2 get_next_line.a 2> /dev/null gcc -o tmp/binary ${SRCPATH}$2 get_next_line.a 2> /dev/null
valgrind --leak-check=full ./tests/tmp/binary 2> tests/tmp/memorycheck > /dev/null valgrind --leak-check=full ./tmp/binary 2> tmp/memorycheck > /dev/null
cat tests/tmp/memorycheck | grep indirectly | grep "[123456789] bytes" > /dev/null cat tmp/memorycheck | grep indirectly | grep "[123456789] bytes" > /dev/null
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
printf "\n\e[1;31mLeaks Valgrind $1 $2\e[0;00m\n" printf "\n\e[1;31mLeaks Valgrind $1 $2\e[0;00m\n"
cat tests/tmp/memorycheck cat tmp/memorycheck
FAULTS=$(($FAULTS+1)) FAULTS=$(($FAULTS+1))
CURFUNERR=1 CURFUNERR=1
else else
printf "\e[1;32mNo Leaks Valgrind\e[0;00m\n" printf "\e[1;32mNo Leaks Valgrind\e[0;00m\n"
fi fi
cat tests/tmp/memorycheck | grep definitely | grep "[123456789] bytes" > /dev/null cat tmp/memorycheck | grep definitely | grep "[123456789] bytes" > /dev/null
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
printf "\n\e[1;31mLeaks Valgrind $1 $2\e[0;00m\n" printf "\n\e[1;31mLeaks Valgrind $1 $2\e[0;00m\n"
cat tests/tmp/memorycheck cat tmp/memorycheck
FAULTS=$(($FAULTS+1)) FAULTS=$(($FAULTS+1))
CURFUNERR=1 CURFUNERR=1
fi fi
@ -110,7 +110,7 @@ checkfile()
if [ $? -ne $2 ] if [ $? -ne $2 ]
then then
printf "\e[1;31mMakefile does not create $1\e[0;00m\n" printf "\e[1;31mMakefile does not create $1\e[0;00m\n"
rm -rf tests/tmp rm -rf tmp
exit 1 exit 1
fi fi
} }
@ -148,11 +148,11 @@ checkrule()
relinkcheck() relinkcheck()
{ {
make $1 2>&1 | grep -v Nothing > tests/tmp/relink && cat tests/tmp/relink | grep -v directory > /dev/null make $1 2>&1 | grep -v Nothing > tmp/relink && cat tmp/relink | grep -v directory > /dev/null
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
printf "\n\e[1;31mMakefile relinks\e\n[0;00m" printf "\n\e[1;31mMakefile relinks\e\n[0;00m"
cat tests/tmp/relink cat tmp/relink
FAULTS=$(($FAULTS+1)) FAULTS=$(($FAULTS+1))
else else
printf "\e[1;32mMakefile OK\n\e[0;00m" printf "\e[1;32mMakefile OK\n\e[0;00m"
@ -163,11 +163,11 @@ relinkcheck()
# Test 1 # Test 1
printf "\e[1;36mTest 1 Checking all source with Norminette\e[0;00m\n" printf "\e[1;36mTest 1 Checking all source with Norminette\e[0;00m\n"
norminette $(find ./ -name '*.[ch]' | grep -v ./tests/ | grep -v ccls) > tests/tmp/norm norminette $(find ./ -name '*.[ch]' | grep -v ./tests/ | grep -v ccls) > tmp/norm
if [ $? -eq 1 ] if [ $? -eq 1 ]
then then
printf "\e[1;31mYour shit is not norm!\e[0;00m\n" printf "\e[1;31mYour shit is not norm!\e[0;00m\n"
cat tests/tmp/norm cat tmp/norm
FAULTS=$(($FAULTS+1)) FAULTS=$(($FAULTS+1))
else else
printf "\e[1;32mNorminette OK\e[0;00m\n" printf "\e[1;32mNorminette OK\e[0;00m\n"
@ -334,7 +334,7 @@ find ./ -name '*bonus.h' | grep bonus > /dev/null
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
HEADLOC=$(find ./ -name '*bonus.h') HEADLOC=$(find ./ -name '*bonus.h')
cp $HEADLOC tests/tmp/get_next_line.h cp $HEADLOC tmp/get_next_line.h
fi fi
printf "\e[1;36mTest 29 Checking if Makefile bonus rule exists\e[0;00m\n" printf "\e[1;36mTest 29 Checking if Makefile bonus rule exists\e[0;00m\n"
make fclean > /dev/null make fclean > /dev/null
@ -346,12 +346,12 @@ then
then then
printf "\e[1;35mBut we got no errors, Congratulations\e[0;00m\n" printf "\e[1;35mBut we got no errors, Congratulations\e[0;00m\n"
make fclean > /dev/null make fclean > /dev/null
rm -rf tests/tmp rm -rf tmp
exit 0 exit 0
else else
printf "\e[1;31mAnd we got $FAULTS errors\nSo that's a bummer\e[0;00m\n" printf "\e[1;31mAnd we got $FAULTS errors\nSo that's a bummer\e[0;00m\n"
make fclean > /dev/null make fclean > /dev/null
rm -rf tests/tmp rm -rf tmp
exit 1 exit 1
fi fi
fi fi
@ -390,9 +390,9 @@ then
else else
printf "\e[1;31mwe got $FAULTS errors\nSo that's a bummer\e[0;00m\n" printf "\e[1;31mwe got $FAULTS errors\nSo that's a bummer\e[0;00m\n"
make fclean > /dev/null make fclean > /dev/null
rm -rf tests/tmp rm -rf tmp
exit 1 exit 1
fi fi
make fclean > /dev/null make fclean > /dev/null
rm -rf tests/tmp rm -rf tmp
exit 0 exit 0