diff --git a/test.sh b/test.sh index 47041c9..71c74a5 100755 --- a/test.sh +++ b/test.sh @@ -6,7 +6,7 @@ # 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" fi HEADLOC=$(find ./ -name '*line.h' | grep -v tests | grep -v ccls) -mkdir -p tests/tmp -cp $HEADLOC tests/tmp/get_next_line.h +mkdir -p tmp +cp $HEADLOC tmp/get_next_line.h if [ $1 == "old" ] then SRCPATH="tests/src/old/" @@ -38,7 +38,7 @@ then FILPATH="tests/files/new/" 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" - rm -rf tests/tmp + rm -rf tmp exit 1 fi if [ $2 ] @@ -50,9 +50,9 @@ fi getnextline() { - gcc -D BUFFER_SIZE=$1 -o tests/tmp/binary ${SRCPATH}$2 get_next_line.a - ./tests/tmp/binary > tests/tmp/output - diff ${FILPATH}$3 tests/tmp/output > /dev/null + gcc -D BUFFER_SIZE=$1 -o tmp/binary ${SRCPATH}$2 get_next_line.a + ./tmp/binary > tmp/output + diff ${FILPATH}$3 tmp/output > /dev/null if [ $? -eq 0 ] then printf "\e[1;32mOutput OK\e[0;00m\n" @@ -60,44 +60,44 @@ getnextline() printf "\e[1;31mOutput is wrong\e[0;00m\n" FAULTS=$(($FAULTS+1)) fi - gcc -g -fsanitize=address -D BUFFER_SIZE=$1 -o tests/tmp/binary ${SRCPATH}$2 get_next_line.a - ./tests/tmp/binary > tests/tmp/output 2>tests/tmp/memorycheck - diff ${FILPATH}$3 tests/tmp/output > /dev/null + gcc -g -fsanitize=address -D BUFFER_SIZE=$1 -o tmp/binary ${SRCPATH}$2 get_next_line.a + ./tmp/binary > tmp/output 2>tmp/memorycheck + diff ${FILPATH}$3 tmp/output > /dev/null if [ $? -eq 0 ] then - cat tests/tmp/memorycheck | grep "leaked" > /dev/null + cat tmp/memorycheck | grep "leaked" > /dev/null if [ $? -eq 1 ] then 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 + cat tmp/memorycheck FAULTS=$(($FAULTS+1)) fi else printf "\e[1;31mKO with fsanitize\e[0;00m\n" - cat tests/tmp/memorycheck + cat 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 + gcc -o tmp/binary ${SRCPATH}$2 get_next_line.a 2> /dev/null + valgrind --leak-check=full ./tmp/binary 2> tmp/memorycheck > /dev/null + cat 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 + cat 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 + cat 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 + cat tmp/memorycheck FAULTS=$(($FAULTS+1)) CURFUNERR=1 fi @@ -110,7 +110,7 @@ checkfile() if [ $? -ne $2 ] then printf "\e[1;31mMakefile does not create $1\e[0;00m\n" - rm -rf tests/tmp + rm -rf tmp exit 1 fi } @@ -148,11 +148,11 @@ checkrule() 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 ] then printf "\n\e[1;31mMakefile relinks\e\n[0;00m" - cat tests/tmp/relink + cat tmp/relink FAULTS=$(($FAULTS+1)) else printf "\e[1;32mMakefile OK\n\e[0;00m" @@ -163,11 +163,11 @@ relinkcheck() # Test 1 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 ] then printf "\e[1;31mYour shit is not norm!\e[0;00m\n" - cat tests/tmp/norm + cat tmp/norm FAULTS=$(($FAULTS+1)) else printf "\e[1;32mNorminette OK\e[0;00m\n" @@ -334,7 +334,7 @@ find ./ -name '*bonus.h' | grep bonus > /dev/null if [ $? -eq 0 ] then HEADLOC=$(find ./ -name '*bonus.h') - cp $HEADLOC tests/tmp/get_next_line.h + cp $HEADLOC tmp/get_next_line.h fi printf "\e[1;36mTest 29 Checking if Makefile bonus rule exists\e[0;00m\n" make fclean > /dev/null @@ -346,12 +346,12 @@ then then printf "\e[1;35mBut we got no errors, Congratulations\e[0;00m\n" make fclean > /dev/null - rm -rf tests/tmp + rm -rf tmp exit 0 else printf "\e[1;31mAnd we got $FAULTS errors\nSo that's a bummer\e[0;00m\n" make fclean > /dev/null - rm -rf tests/tmp + rm -rf tmp exit 1 fi fi @@ -390,9 +390,9 @@ then else printf "\e[1;31mwe got $FAULTS errors\nSo that's a bummer\e[0;00m\n" make fclean > /dev/null - rm -rf tests/tmp + rm -rf tmp exit 1 fi make fclean > /dev/null -rm -rf tests/tmp +rm -rf tmp exit 0