diff --git a/README.md b/README.md index 6172a08..a45c291 100644 --- a/README.md +++ b/README.md @@ -58,35 +58,7 @@ I think from this you pretty much can figure it out, it isn't a big change :) --- -# How To Launch The Tester -Clone it to the root of your minishell - -cd to the testers folder -## Options - -```bash -bash tester.sh m -``` -```bash -bash tester.sh vm -``` -```bash -bash tester.sh ne -``` -```bash -bash tester.sh d -``` -```bash -bash tester.sh b -``` -```bash -bash tester.sh a -``` - ---- - # How To Install and Run - To install the script, copy and run following command: ``` @@ -105,6 +77,47 @@ mstest --- +# How To Launch The Tester + +Do this if not using the `mstest` alias: +* Clone it to the root of your minishell +* cd to the tester's folder + +## Options +Of course if using the `mstest` alias, +use that instead of `bash tester.sh`. +So a command should look like this: +`mstest help` or `mstest m` and etc. + +When using the `mstest` alias, you don't +need to cd to the tester's folder. + +Some options are not shown here, +run the help command to see them! + +Print all options: +```bash +bash tester.sh help +``` +Mandatory tests: +```bash +bash tester.sh m +``` +Mandatory tests (with valgrind): +```bash +bash tester.sh vm +``` +Tests for bonus from PDF: +```bash +bash tester.sh b +``` +Tests both mandatory and bonus: +```bash +bash tester.sh a +``` + +--- + # Updates Tests without environment now are updated, separated and can be run with: diff --git a/cmds/extra/1_extra.sh b/cmds/extra/1_extra.sh new file mode 100644 index 0000000..70f17af --- /dev/null +++ b/cmds/extra/1_extra.sh @@ -0,0 +1,161 @@ +# echo external +/bin/echo \$USER + +/bin/echo \\$USER + +/bin/echo \\\$USER + +/bin/echo \\\\$USER + +/bin/echo \\\\\$USER + +/bin/echo \\\\\\\\\$USER + +/bin/echo \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\$USER \$PATH \\$PWD + +# echo builtin +echo \$USER + +echo \\$USER + +echo \\\$USER + +echo \\\\$USER + +echo \\\\\$USER + +echo \\\\\\\\\$USER + +echo \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\$USER \$PATH \\$PWD + +# cd +cd -- + +cd ../../ +cd - +cd - + +echo cd ~ +echo "cd ~" + +pwd +cd ~ +cd - ananas dot jpeg +pwd + +pwd +cd ~ asd w dd q asd +pwd + +pwd +cd ~ +cd - +pwd + +pwd +cd - +pwd + +pwd +cd ~ +pwd + +cd '/////' 2>/dev/null + +cd "doesntexist" 2>/dev/null + +cd "wtf" 2>/dev/null + +# env +env what + +# export +export -TEST=100 + +export --TEST=123 + +# the ordering of export doesn't matter, +# for declare to still work +export + +export TEST+=100 + +# unset +unset TES;T + +unset -TEST + +# pipes +ls | cat << stop | ls -la | cat << stop1 | ls | cat << stop2 | ls -la > > out | cat << stop3 +fe +wf +fwe +f +stop +dw +stop1 +dwasd +stop2 +cat Makefile | ls > out +cat out +/bin/rm -f out + +/bin/env | grep "_=" + +/bin/env | grep "SHLVL" + +# scmds +touch " +" +/bin/rm -f " +" + +# path fails +unset PATH +echo $PATH +/bin/ls +echo 1 +cd - +echo 42 + +env -i ./minishell +cd /bin/ +ls + +pwd +cd ~/Desktop/ +pwd + +# syntax errors +~ + +. + +.. + +>echo> +/bin/rm -f echo + +>echo>> +/bin/rm -f echo + +\\\ + +>| echo wtf +/bin/rm -rf echo + +# go wild +echo "env | /usr/bin/wc -l" | env -i $MINISHELL_PATH"/"$EXECUTABLE +echo $? + +echo "ls" | env -i $MINISHELL_PATH"/"$EXECUTABLE +echo $? + +echo "unset PATH" | env -i $MINISHELL_PATH"/"$EXECUTABLE +echo $? + +# parsing hell +>| echo sure diff --git a/cmds/mand/0_compare_parsing.sh b/cmds/mand/0_compare_parsing.sh index dacb8ba..f0a01da 100644 --- a/cmds/mand/0_compare_parsing.sh +++ b/cmds/mand/0_compare_parsing.sh @@ -49,20 +49,6 @@ /bin/echo "'$?'" -/bin/echo \$USER - -/bin/echo \\$USER - -/bin/echo \\\$USER - -/bin/echo \\\\$USER - -/bin/echo \\\\\$USER - -/bin/echo \\\\\\\\\$USER - -/bin/echo \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\$USER \$PATH \\$PWD - /bin/echo "cat lol.c | cat > lol.c" /bin/echo "cat lol.c '|' cat > lol.c" @@ -179,4 +165,4 @@ /bin/echo ''totally logical'' -/bin/echo ""'totally logical'"" \ No newline at end of file +/bin/echo ""'totally logical'"" diff --git a/cmds/mand/10_parsing_hell.sh b/cmds/mand/10_parsing_hell.sh index 1317b84..d9d8c77 100644 --- a/cmds/mand/10_parsing_hell.sh +++ b/cmds/mand/10_parsing_hell.sh @@ -315,7 +315,3 @@ exit 9223372036854775805 exit 123"123" <| echo ok - ->| echo sure - -cd -- diff --git a/cmds/mand/1_builtins.sh b/cmds/mand/1_builtins.sh index ad73fbf..03860ba 100644 --- a/cmds/mand/1_builtins.sh +++ b/cmds/mand/1_builtins.sh @@ -4,10 +4,6 @@ ### ECHO ### -echo cd ~ - -echo "cd ~" - echo ""$?"" echo $?"42" @@ -56,20 +52,6 @@ echo '$?' echo "'$?'" -echo \$USER - -echo \\$USER - -echo \\\$USER - -echo \\\\$USER - -echo \\\\\$USER - -echo \\\\\\\\\$USER - -echo \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\$USER \$PATH \\$PWD - echo "cat lol.c | cat > lol.c" echo "cat lol.c '|' cat > lol.c" @@ -130,7 +112,6 @@ echo $USER$TESTNOTFOUND$HOME$ echo $USER$TESTNOTFOUND$HOME$WTF$PWD - echo -n test1 echo -n "test1 test2" @@ -150,6 +131,7 @@ echo -n -n test1 echo -n -n -n -n -n test1 echo - + echo -- echo " -nn " @@ -195,8 +177,10 @@ pwd cd .. pwd +pwd cd .. cd $OLDPWD +pwd pwd cd . @@ -207,7 +191,7 @@ cd "." pwd pwd -cd /Users +cd /usr/local pwd pwd @@ -230,30 +214,22 @@ pwd cd "$PWD/file_tests" pwd -cd '/////' 2>/dev/null - -cd '/etc' - -cd '/var' +pwd +cd '/etc' +pwd -cd "doesntexist" 2>/dev/null +pwd +cd '/var' +pwd +pwd cd ../../.. - -cd "wtf" 2>/dev/null - -cd ? - -cd + - -cd _ +pwd cd woof cd bark bark -cd '/' - pwd cd "doesntexist" pwd @@ -287,10 +263,6 @@ pwd cd _ pwd -cd ../../ -cd - -cd - - pwd cd echo pwd @@ -311,33 +283,11 @@ pwd cd $OLDPWD/something pwd -pwd -cd ~ -cd - ananas dot jpeg -pwd - # might need to change the directory by yourself, that supposed to be valid =) pwd cd includes/ djhwbdhwbd wgdyuhgw jdwjdh wuiydjwh pwd -pwd -cd ~ asd w dd q asd -pwd - -pwd -cd ~ -cd - -pwd - -pwd -cd - -pwd - -pwd -cd ~ -pwd - # might need to change the directory by yourself, that supposed to be valid =) pwd cd ../libft @@ -357,8 +307,6 @@ env | grep USER env | wc -l -env what - ### PWD ### pwd @@ -387,8 +335,6 @@ env | grep HOME export =============123 -export - export = export =42 @@ -417,28 +363,26 @@ export TEST=123 export ___TEST=123 -export --TEST=123 - export ''='' +export ""="" + export "="="=" export '='='=' -export TE-ST=100 +export ========== + +export =============123 -export -TEST=100 +export TE-ST=100 export TEST-=100 export _TEST=100 -export ========== - export 1TEST= -export ""="" - export TES=T="" export TE+S=T="" @@ -457,8 +401,6 @@ export TES{T=123 export TES-T=123 -export -TEST=123 - export _TEST=123 export TES_T=123 @@ -475,8 +417,6 @@ export TES!T=123 export TES$?T=123 -export =============123 - export +++++++=123 export ________=123 @@ -487,8 +427,6 @@ export TES!T=123 export TES\~T=123 -export TEST+=100 - export TES_T=123 /bin/echo $TES_T env | grep TES_T @@ -537,8 +475,6 @@ unset "$" unset $"" -export TEST=100 - unset doesntexist unset OLDPWD @@ -549,8 +485,6 @@ unset PATH unset PATH -unset TES;T - unset TES.T unset TES+T @@ -563,8 +497,6 @@ unset TES{T unset TES-T -unset -TEST - unset _TEST unset TES_T diff --git a/cmds/mand/1_pipelines.sh b/cmds/mand/1_pipelines.sh index d759459..0967e96 100644 --- a/cmds/mand/1_pipelines.sh +++ b/cmds/mand/1_pipelines.sh @@ -29,10 +29,6 @@ echo 42 | echo no | echo smth | grep no echo 42 | echo no | echo smth | grep smth -/bin/env | grep "_=" - -/bin/env | grep "SHLVL" - /bin/echo 1 | kaka echo test | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e @@ -93,20 +89,6 @@ as $HOME stop3 /bin/rm -f out -ls | cat << stop | ls -la | cat << stop1 | ls | cat << stop2 | ls -la > > out | cat << stop3 -fe -wf -fwe -f -stop -dw -stop1 -dwasd -stop2 -cat Makefile | ls > out -cat out -/bin/rm -f out - ls | cat << stop | ls -la > out0| cat << stop1 | ls | cat << stop2 | ls -la >> out | cat << stop3 fe wf @@ -147,7 +129,6 @@ ls|cat Makefile|> out ls|cat Makefile|>> out /bin/rm -f out - ls|cat Makefile|cat<out $USER asd @@ -173,4 +154,4 @@ cd .. |ls|cat Makefile|>> out pwd /bin/rm -f out -ls -l | awk '$1 ~ /^d/ {print $9}' \ No newline at end of file +ls -l | awk '$1 ~ /^d/ {print $9}' diff --git a/cmds/mand/1_scmds.sh b/cmds/mand/1_scmds.sh index 9b65ad1..cca3efe 100644 --- a/cmds/mand/1_scmds.sh +++ b/cmds/mand/1_scmds.sh @@ -15,12 +15,6 @@ touch "" touch " " /bin/rm -f " " - -touch " -" -/bin/rm -f " -" - mkdir " " /bin/rm -rf " " @@ -114,5 +108,3 @@ rm -f something | echo -n oui | | | - - diff --git a/cmds/mand/2_path_check.sh b/cmds/mand/2_path_check.sh index 99dcea9..af8a32e 100644 --- a/cmds/mand/2_path_check.sh +++ b/cmds/mand/2_path_check.sh @@ -2,13 +2,6 @@ # PATH FAILS # # **************************************************************************** # -unset PATH -echo $PATH -/bin/ls -echo 1 -cd - -echo 42 - unset PATH echo 42 unset PATH @@ -23,13 +16,9 @@ echo $PATH echo 1 -cd - - +pwd +unset PATH cd . - -cd ~ - -cd ~/Desktop/ pwd export PATH= @@ -40,10 +29,6 @@ export PATH=1 echo $PATH echo 1 -env -i ./minishell -cd /bin/ -ls - touch tmp_x_file1 tmp_x_file1 echo $? @@ -63,7 +48,10 @@ echo $? echo 42 /bin/rm -f tmp_x_file1 +pwd +unset PATH cd doesntexist +pwd export PATH="" ls diff --git a/cmds/mand/8_syntax_errors.sh b/cmds/mand/8_syntax_errors.sh index 91449e2..9a8ff33 100644 --- a/cmds/mand/8_syntax_errors.sh +++ b/cmds/mand/8_syntax_errors.sh @@ -16,8 +16,6 @@ <<<<<<<<< -~ - < < < < < < /bin/cat >< @@ -30,25 +28,12 @@ echo > echo > < -. - -.. - echo | | EechoE .echo. ->echo> -/bin/rm -f echo - ->echo>> -/bin/rm -f echo - |echo| trying to destroy your minishell @@ -79,8 +64,6 @@ cat wouaf wouaf / -\\\ - rm -f something | echo -n oui @@ -97,9 +80,6 @@ your minishell is perfect >>| echo wtf ->| echo wtf -/bin/rm -rf echo - <| echo wtf echo "<<| echo wtf" @@ -112,4 +92,4 @@ echo "<| echo wtf" <> -< > \ No newline at end of file +< > diff --git a/cmds/mand/9_go_wild.sh b/cmds/mand/9_go_wild.sh index 741a8e5..f931a81 100644 --- a/cmds/mand/9_go_wild.sh +++ b/cmds/mand/9_go_wild.sh @@ -43,15 +43,6 @@ unset PATH HOME echo $PATH echo $HOME -echo "env | /usr/bin/wc -l" | env -i $MINISHELL_PATH"/"$EXECUTABLE -echo $? - -echo "ls" | env -i $MINISHELL_PATH"/"$EXECUTABLE -echo $? - -echo "unset PATH" | env -i $MINISHELL_PATH"/"$EXECUTABLE -echo $? - echo Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi imperdiet orci nec quam lobortis scelerisque. Morbi scelerisque leo molestie justo semper condimentum. Proin hendrerit ut nulla in mattis. Curabitur velit turpis, congue ut aliquam id, condimentum at dolor. Quisque ultricies neque in tellus pretium, vitae porta ipsum vestibulum. Vivamus cursus volutpat diam, at interdum erat fringilla ac. In nisl quam, ultrices vitae cursus ut, aliquam sed lacus. Suspendisse ac turpis fermentum, pulvinar risus quis, molestie elit. Mauris faucibus eget est vitae efficitur. Mauris feugiat enim in posuere auctor. Morbi lorem lorem, pellentesque et viverra vitae, ullamcorper a mauris. Cras blandit pulvinar accumsan. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aenean id hendrerit elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi imperdiet orci nec quam lobortis scelerisque. Morbi scelerisque leo molestie justo semper condimentum. Proin hendrerit ut nulla in mattis. Curabitur velit turpis, congue ut aliquam id, condimentum at dolor. Quisque ultricies neque in tellus pretium, vitae porta ipsum vestibulum. Vivamus cursus volutpat diam, at interdum erat fringilla ac. In nisl quam, ultrices vitae cursus ut, aliquam sed lacus. Suspendisse ac turpis fermentum, pulvinar risus quis, molestie elit. Mauris faucibus eget est vitae efficitur. Mauris feugiat enim in posuere auctor. Morbi lorem lorem, pellentesque et viverra vitae, ullamcorper a mauris. Cras blandit pulvinar accumsan. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aenean id hendrerit elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi imperdiet orci nec quam lobortis scelerisque. Morbi scelerisque leo molestie justo semper condimentum. Proin hendrerit ut nulla in mattis. Curabitur velit turpis, congue ut aliquam id, condimentum at dolor. Quisque ultricies neque in tellus pretium, vitae porta ipsum vestibulum. Vivamus cursus volutpat diam, at interdum erat fringilla ac. In nisl quam, ultrices vitae cursus ut, aliquam sed lacus. Suspendisse ac turpis fermentum, pulvinar risus quis, molestie elit. Mauris faucibus eget est vitae efficitur. Mauris feugiat enim in posuere auctor. Morbi lorem lorem, pellentesque et viverra vitae, ullamcorper a mauris. Cras blandit pulvinar accumsan. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aenean id hendrerit elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi imperdiet orci nec quam lobortis scelerisque. Morbi scelerisque leo molestie justo semper condimentum. Proin hendrerit ut nulla in mattis. Curabitur velit turpis, congue ut aliquam id, condimentum at dolor. Quisque ultricies neque in tellus pretium, vitae porta ipsum vestibulum. Vivamus cursus volutpat diam, at interdum erat fringilla ac. In nisl quam, ultrices vitae cursus ut, aliquam sed lacus. Suspendisse ac turpis fermentum, pulvinar risus quis, molestie elit. Mauris faucibus eget est vitae efficitur. Mauris feugiat enim in posuere auctor. Morbi lorem lorem, pellentesque et viverra vitae, ullamcorper a mauris. Cras blandit pulvinar accumsan. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aenean id hendrerit elit. diff --git a/tester.sh b/tester.sh index 4406c45..b0014ed 100755 --- a/tester.sh +++ b/tester.sh @@ -59,18 +59,29 @@ main() { echo -e " 🚀 \033[1;34mMINI_DEATH\033[m 🚀" echo " 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀" test_mini_death + elif [[ $1 == "x" ]] ; then + echo " 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀" + echo -e " 🚀 \033[1;34mEXTRA\033[m 🚀" + echo " 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀" + test_extra elif [[ $1 == "-f" ]] ; then [[ ! -f $2 ]] && echo "\"$2\" FILE NOT FOUND" [[ -f $2 ]] && test_from_file $2 else - echo "usage: mstest [m,vm,ne,b,a]" + echo "It's a good idea to try out a lot" + echo "of non-mandatory tests," + echo "just to check for segfaults." + echo "" + echo "usage: mstest [m,b,a,vm,ne,d,x,-f]" echo "m: mandatory tests" - echo "vm: mandatory tests with valgrind" - echo "ne: tests without environment" echo "b: bonus tests" echo "a: mandatory and bonus tests" + echo "vm: mandatory tests with valgrind" + echo "ne: tests without environment" echo "d: mandatory pipe segfault test (BRUTAL)" - + echo "x: extra tests, not required by the PDF" + echo "-f: use tests from a specific file," + echo "given as full path" fi if [[ $TEST_COUNT -gt 0 ]] ; then print_stats @@ -103,6 +114,14 @@ test_mandatory() { done } +test_extra() { + FILES="${RUNDIR}/cmds/extra/*" + for file in $FILES + do + test_from_file $file + done +} + test_mini_death() { FILES="${RUNDIR}/cmds/mini_death/*" for file in $FILES