Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- test_passed=0
- test_fail=0
- number_of_test_sh2=0
- echo -e "Integration tests by mariusvnh, zuldruck, simontraww(sh && sh2)"
- echo -e "\n\nGoog Luck!\n"
- echo -e "english version of you bash actived..\n"
- LANG=en_us_8859_1
- export LANG=en_us_8859_1
- #simple exit
- echo "exit" | ./42sh &> log.txt
- if [ $? != 0 ]; then
- echo -e "simple exit: Return value was $?\nExpected 0\n"
- else {
- echo -e "simple exit: PASSED\n"
- ((test_passed++))
- }
- fi
- DIFF=$(diff <(cat log.txt) <(echo "exit"))
- if [ "$DIFF" != "" ]; then
- echo -e "simple exit: Got: $DIFF\nExpected: \"\"\n"
- else
- echo -e "simple exit [2]: PASSED\n"
- ((test_passed++))
- fi
- #exit test
- echo "exit 43" | ./42sh &> log.txt
- echo "exit 43" | tcsh &> tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "exit 43: Got: $DIFF\nExpected: \"\"\n"
- else {
- echo -e "exit 43: PASSED\n"
- ((test_passed++))
- }
- fi
- #exit test
- echo "exit test" | ./42sh &> log.txt
- echo "exit test" | tcsh &> tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "exit test: Got: $DIFF\nExpected: \"\"\n"
- else {
- echo -e "exit test: PASSED\n"
- ((test_passed++))
- }
- fi
- #exit 42test
- echo "exit 42test" | ./42sh &> log.txt
- echo "exit 42test" | tcsh >& tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "exit 42test: Got: $DIFF\nExpected: \"\"\n"
- else {
- echo -e "exit 42test: PASSED\n"
- ((test_passed++))
- }
- fi
- #exit badly [SIMONTRAWW]
- echo "exit -77j" | ./42sh &> log.txt
- echo "exit -77j" | tcsh &> tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "exit -77j: Got: $DIFF\nExpected: \"\"\n"
- else {
- echo -e "exit -77j: PASSED\n"
- ((test_passed++))
- }
- fi
- #pwd
- echo -e "cd ..\npwd" | ./42sh &> log.txt
- echo -e "cd ..\npwd" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "cd .. --> pwd: Got: $DIFF\nExpected: \"\"\n"
- else {
- echo -e "cd .. --> pwd: PASSED\n"
- ((test_passed++))
- }
- fi
- #env path presence
- echo -e "env" | ./42sh &> log.txt
- DIFF=$(cat log.txt | grep "^PATH=" | wc -l)
- if [ "$DIFF" != "1" ]; then
- echo -e "env PATH check: Got: $DIFF\nExpected: \"1\"\n"
- else {
- echo -e "env PATH check: PASSED\n"
- ((test_passed++))
- }
- fi
- #setenv
- echo -e "setenv SALUT PUTE\nenv" | ./42sh &> log.txt
- DIFF=$(cat log.txt | grep "^SALUT=PUTE" | wc -l)
- if [ "$DIFF" != "1" ]; then
- echo -e "setenv test: Got: $DIFF\nExpected: \"1\"\n"
- else {
- echo -e "setenv test: PASSED\n"
- ((test_passed++))
- }
- fi
- #setenv
- echo -e "unsetenv PATH\nenv" | ./42sh &> log.txt
- DIFF=$(cat log.txt | grep "^PATH" | wc -l)
- if [ "$DIFF" != "0" ]; then
- echo -e "unsetenv test: Got: $DIFF\nExpected: \"1\"\n"
- else {
- echo -e "unsetenv test: PASSED\n"
- ((test_passed++))
- }
- fi
- #setenv
- mkdir lstest
- mkdir lstest/plouplou
- touch lstest/salut.txt
- touch lstest/lala.txt
- touch lstest/plouplou/yop.txt
- cd lstest
- echo -e "cd plouplou\nls" | ./../42sh &> log.txt
- echo -e "cd plouplou\nls" | tcsh &> tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "ls: AAAGot: $DIFF\n"
- else {
- echo -e "ls: PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST LONG SPACES [SIMONTRAWW]
- echo "ls " | ./../42sh &>log.txt
- echo "ls " | tcsh &>tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "TEST LONG WHITESPACES : Got: $DIFF\n"
- else {
- echo -e "TEST LONG WHITESPACES : PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST WITH TAB [SIMONTRAWW]
- echo "ls " | ./../42sh &>log.txt
- echo "ls " | tcsh &>tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "TEST WITH TAB : Got: $DIFF\n"
- else {
- echo -e "TEST WITH TAB : PASSED\n"
- ((test_passed++))
- }
- fi
- cd ..
- rm -rf lstest
- #TEST WITH spaces [SIMONTRAWW]
- echo "cd ../" | ./42sh &>log.txt
- echo "cd ../" | tcsh &>tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "TEST CD ../ WITH SPACES : Got: $DIFF\n"
- else {
- echo -e "TEST CD ../ WITH SPACES : PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST WITH TAB [SIMONTRAWW]
- echo -e "\t\tcd\t" | ./42sh &>log.txt
- echo -e "\t\tcd\t" | tcsh &>tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "TEST CD WITH tab : Got: $DIFF\n"
- else {
- echo -e "TEST CD WITH tab : PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST CHMOD -x [SIMONTRAWW]
- touch foobar
- echo "echo \"fail\"" | > foobar
- echo -e "chmod -x ./foobar\n./foobar" |./42sh &> log.txt
- echo -e "chmod -x ./foobar\n./foobar" | tcsh &> tcssh.txt
- rm -rf foobar
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "TEST CHMOD: Got: $DIFF\n"
- else {
- echo -e "TEST CHMOD: PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST ERROR + one or two letter after word [SIMONTRAWW]
- echo -e "exitt" | ./42sh &> log.txt
- echo -e "exitt" | tcsh &> tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "TEST EXITT (one two letter at the end of word): Got: $DIFF\n"
- else {
- echo -e "TEST EXITT (one two letter at the end of word): PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST CHMOD +x on picture [SIMONTRAWW]
- wget http://convertir-une-image.com/frontframe/images/cute_ball_info.png &> /dev/null
- mv cute_ball_info.png test.png &> /dev/null
- echo -e "chmod +x test.png\n./test.png" | ./42sh &> log.txt
- echo -e "chmod +x test.png\n./test.png" | tcsh &> tcssh.txt
- rm -rf test.png
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "TEST EXEC IMG: Got: $DIFF\n"
- else {
- echo -e "TEST EXEC IMG: PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST programm segfault [SIMONTRAWW]
- mkdir tests
- cd tests
- wget http://epi2022.fr/neo/PSU/PSU_minishell1_2017/segfault.c &> /dev/null
- echo -e "gcc segfault.c\n./a.out" | ./../42sh &> log.txt
- echo -e "gcc segfault.c\n./a.out" | tcsh &> tcssh.txt
- rm -rf segfault.c &> /dev/null
- rm -rf a.out &> /dev/null
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "TEST SEGFAULT: Got: $DIFF\n"
- else {
- echo -e "TEST SEGFAULT: PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST programm floating point exeception [SIMONTRAWW]
- wget http://epi2022.fr/neo/PSU/PSU_minishell1_2017/floating.c &> /dev/null
- echo "gcc floating.c -lm" | ./../42sh &> /dev/null
- echo "gcc floating.c -lm" | tcsh &> /dev/null
- echo -e "gcc floating.c -lm\n./a.out" | ./../42sh &> log.txt
- echo -e "gcc floating.c -lm\n./a.out" | tcsh &> tcssh.txt
- rm -rf floating.c
- rm -rf a.out
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "TEST FLOATING point exception: Got: $DIFF\n"
- else {
- echo -e "TEST FLOATING point exception: PASSED\n"
- ((test_passed++))
- }
- fi
- cd ..
- rm -rf tests
- #TEST ERROR + one or two letter after word [SIMONTRAWW]
- echo -e "unsetenvv" | ./42sh &> log.txt
- echo -e "unsetenvv" | tcsh &> tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "TEST unsetenvv (one two letter at the end of word): Got: $DIFF\n"
- else {
- echo -e "TEST unsetenvv (one two letter at the end of word): PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST ERROR + one or two letter after word [SIMONTRAWW]
- echo -e "setenvi" | ./42sh &> log.txt
- echo -e "setenvi" | tcsh &> tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "TEST setenvi (one two letter at the end of word): Got: $DIFF\n"
- else {
- echo -e "TEST setenvi (one two letter at the end of word): PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST cd [SIMONTRAWW]
- echo -e "cd\npwd" | ./42sh &>log.txt
- echo -e "cd\npwd" | tcsh &>tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "TEST cd : Got: $DIFF\n"
- else {
- echo -e "TEST cd : PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST cd ../ [SIMONTRAWW]
- echo -e "cd ../\npwd" | ./42sh &>log.txt
- echo -e "cd ../\npwd" | tcsh &>tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "TEST cd ../ : Got: $DIFF\n"
- else {
- echo -e "TEST cd ../ : PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST cd /dev [SIMONTRAWW]
- echo -e "cd /dev\npwd" | ./42sh &>log.txt
- echo -e "cd /dev\npwd" | tcsh &>tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "TEST cd /dev : Got: $DIFF\n"
- else {
- echo -e "TEST cd /dev : PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST cd NULL [SIMONTRAWW]
- echo -e "cd NULL" | ./42sh &>log.txt
- echo -e "cd NULL" | tcsh &>tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "TEST cd NULL directory : Got: $DIFF\n"
- else {
- echo -e "TEST cd NULL directory : PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST cd random dirr [SIMONTRAWW]
- echo -e "cd ../../../../../../../../\npwd" | ./42sh &>log.txt
- echo -e "cd ../../../../../../../../\npwd" | tcsh &>tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "TEST random dirr : Got: $DIFF\n"
- else {
- echo -e "TEST random dirr : PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST cd moins without any OLDPWD [SIMONTRAWW]
- echo -e "cd ../\ncd -\npwd" | ./42sh &>log.txt
- echo -e "cd ../\ncd -\npwd" | tcsh &>tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "TEST cd moins without OLDPWD : Got: $DIFF\n"
- else {
- echo -e "TEST cd moins without OLDPWD: PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST NAME TOO LONG [SIMONTRAWW]
- echo "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | ./42sh &>log.txt ./42sh &> /dev/null
- echo "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | tcsh &>tcssh.txt tcsh &> /dev/null
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "TEST CD NAME TOO LONG: Got: $DIFF\n"
- else {
- echo -e "TEST CD NAME TOO LONG : PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST /bin/ls [SIMONTRAWW]
- echo -e "/bin/ls" | ./42sh &>log.txt
- echo -e "/bin/ls" | tcsh &>tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "TEST /bin/ls: Got: $DIFF\n"
- else {
- echo -e "TEST /bin/ls: PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST /bin/ls [SIMONTRAWW]
- echo -e "/bin/ls" | ./42sh &>log.txt
- echo -e "/bin/ls" | tcsh &>tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "TEST /bin/ls: Got: $DIFF\n"
- else {
- echo -e "TEST /bin/ls: PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST cd bin/pwd [SIMONTRAWW]
- echo -e "cd /bin/pwd" | ./42sh &>log.txt
- echo -e "cd /bin/pwd" | tcsh &>tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "TEST cd /bin/pwd directory : Got: $DIFF\n"
- else {
- echo -e "TEST cd /bin/pwd directory : PASSED\n"
- ((test_passed++))
- }
- fi
- #setenv A 2
- echo -e "setenv A 2\nenv" | ./42sh &> log.txt
- DIFF=$(cat log.txt | grep "^A=2" | wc -l)
- if [ "$DIFF" != "1" ]; then
- echo -e "setenv A 2: Got: $DIFF\nExpected: \"1\"\n"
- else {
- echo -e "setenv A 2: PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST setenv A 2[SIMONTRAWW]
- echo "setenv 2 A" | ./42sh &>log.txt
- echo "setenv 2 A" | tcsh &>tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "SETENV 2 A error msg : Got: $DIFF\n"
- else {
- echo -e "SETENV 2 A error msg : PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST setenv A/ 2[SIMONTRAWW]
- echo "setenv A/ 2" | ./42sh &>log.txt
- echo "setenv A/ 2" | tcsh &>tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "SETENV A/ 2 error msg : Got: $DIFF\n"
- else {
- echo -e "SETENV A/ 2 error msg : PASSED\n"
- ((test_passed++))
- }
- fi
- #TEST setenv A 2[SIMONTRAWW]
- echo "setenv SALU/T 2" | ./42sh &>log.txt
- echo "setenv SALU/T 2" | tcsh &>tcssh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "SETENV SALU/T 2 error msg : Got: $DIFF\n"
- else {
- echo -e "SETENV SALU/T 2 error msg : PASSED\n"
- ((test_passed++))
- }
- fi
- #CD cd -
- echo -e "cd ..\ncd -\npwd" | ./42sh &> log.txt
- echo -e "cd ..\ncd -\npwd" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "cd .. puis cd - puis pwd --> pwd: Got: $DIFF\nExpected: \"\"\n"
- else {
- echo -e "cd .. puis cd - puis pwd --> pwd: PASSED\n"
- ((test_passed++))
- }
- fi
- #CD cd -
- echo -e "cd ..\ncd -\ncd ../\ncd -\ncd ../\ncd -\npwd" | ./42sh &> log.txt
- echo -e "cd ..\ncd -\ncd ../\ncd -\ncd ../\ncd -\npwd" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "cd .. puis cd - puis cd ../ puis cd - (3fois) puis pwd --> pwd: Got: $DIFF\nExpected: \"\"\n"
- else {
- echo -e "cd .. puis cd - puis cd ../ puis cd - (3fois) puis pwd --> pwd: PASSED\n"
- ((test_passed++))
- }
- fi
- #CD cd -
- echo -e "cd ..\ncd -\ncd ../\ncd -\ncd ../\ncd -\npwd" | ./42sh &> log.txt
- echo -e "cd ..\ncd -\ncd ../\ncd -\ncd ../\ncd -\npwd" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "cd .. puis cd - puis cd ../ puis cd - (3fois) puis pwd --> pwd: Got: $DIFF\nExpected: \"\"\n"
- else {
- echo -e "cd .. puis cd - puis cd ../ puis cd - (3fois) puis pwd --> pwd: PASSED\n"
- ((test_passed++))
- }
- fi
- #CD cd -
- echo "setenv 2/A" | ./42sh &> log.txt
- echo "setenv 2/A" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "setenv 2/A --> pwd: Got: $DIFF\nExpected: \"\"\n"
- else {
- echo -e "setenv 2/A --> pwd: PASSED\n"
- ((test_passed++))
- }
- fi
- #Pipe2
- echo "/bin/echo salut |cat|wc -l" | ./42sh &> log.txt
- echo "/bin/echo salut |cat|wc -l" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "Pipe2 --> Pipe2: Got: $DIFF\nExpected: \"\"\n"
- else {
- echo -e "Pipe2 --> Pipe2: PASSED\n"
- ((test_passed++))
- }
- fi
- #Pipe2
- echo "env | grep PWD" | ./42sh &> log.txt
- echo "env | grep PWD" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "Pipe Builtin --> pipe builtin: Got: $DIFF\nExpected: \"\"\n"
- else {
- echo -e "Pipe Builtin --> pipe builtin: PASSED\n"
- ((test_passed++))
- }
- fi
- #Pipe2
- echo "unsetenv PWD ; env | grep PWD" | ./42sh &> log.txt
- echo "unsetenv PWD ; env | grep PWD" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "unsetenv PWD ; env | grep PWD --> pipe builtin: Got: $DIFF\nExpected: \"\"\n"
- else {
- echo -e "unsetenv PWD ; env | grep PWD --> pipe builtin: PASSED\n"
- ((test_passed++))
- }
- fi
- #Pipe2
- echo "setenv | grep PWD" | ./42sh &> log.txt
- echo "setenv | grep PWD" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "cd trololol | cat -e" | ./42sh &> log.txt
- echo "cd trololol | cat -e" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "exit 42 | /bin/echo coucou" | ./42sh &> log.txt
- echo "exit 42 | /bin/echo coucou" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "/bin/echo bonjour |" | ./42sh &> log.txt
- echo "/bin/echo bonjour |" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "cat < superfile | cat -e > salut ; cat salut -e" | ./42sh &> log.txt
- echo "cat < superfile | cat -e > salut ; cat salut -e" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "ls << /bin | cat -e > /dev/null < ls" | ./42sh &> log.txt
- echo "ls << /bin | cat -e > /dev/null < ls" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "||| /bin/echo bonjour |||||" | ./42sh &> log.txt
- echo "||| /bin/echo bonjour |||||" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "/bin/echo | bonjour" | ./42sh &> log.txt
- echo "/bin/echo | bonjour" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "/bin/echo | bonjour |" | ./42sh &> log.txt
- echo "/bin/echo | bonjour |" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "> file env \n cat file | grep PWD" | ./42sh &> log.txt
- echo "> file env \n cat file | grep PWD" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection EXOTIC(look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection EXOTIC(look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "|" | ./42sh &> log.txt
- echo "|" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "<|" | ./42sh &> log.txt
- echo "<|" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "/bin/echo > |" | ./42sh &> log.txt
- echo "/bin/echo > |" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo ">> /bin/echo >>" | ./42sh &> log.txt
- echo ">> /bin/echo >>" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "| cat >> /bin/echo << >> << |" | ./42sh &> log.txt
- echo "| cat >> /bin/echo << >> << |" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "ls | cat < ok" | ./42sh &> log.txt
- echo "ls | cat < ok" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "ls > ok | cat" | ./42sh &> log.txt
- echo "ls > ok | cat" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "ls > ok | cat < lol" | ./42sh &> log.txt
- echo "ls > ok | cat < lol" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "ls / | cat > ok ; cat ok" | ./42sh &> log.txt
- echo "ls / | cat > ok ; cat ok" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "ls / | cat | cat -e | cat > ok ; cat ok" | ./42sh &> log.txt
- echo "ls / | cat | cat -e | cat > ok ; cat ok" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "cat < superfile | cat -e" | ./42sh &> log.txt
- echo "cat < superfile | cat -e" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "ls > file < 42; cat file" | ./42sh &> log.txt
- echo "ls > file < 42; cat file" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "/bin/echo bonjour < salut test > yo ; cat yo" | ./42sh &> log.txt
- echo "/bin/echo bonjour < salut test > yo ; cat yo" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "/bin/echo | cat | cat | cat | wc" | ./42sh &> log.txt
- echo "/bin/echo | cat | cat | cat | wc" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "/bin/echo >> salut >> salut" | ./42sh &> log.txt
- echo "/bin/echo >> salut >> salut" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "/bin/echo >> salut >> salut" | ./42sh &> log.txt
- echo "/bin/echo >> salut >> salut" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "/bin/echo bonjour > salut; /bin/echo bonjour >> salut; cat -e < salut | cat" | ./42sh &> log.txt
- echo "/bin/echo bonjour > salut; /bin/echo bonjour >> salut; cat -e < salut | cat" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "/bin/echo bonjour > salut; /bin/echo bonjour >> salut; cat -e < salut | cat" | ./42sh &> log.txt
- echo "/bin/echo bonjour > salut; /bin/echo bonjour >> salut; cat -e < salut | cat" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "/bin/echo > salut | wc" | ./42sh &> log.txt
- echo "/bin/echo > salut | wc" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "/bin/echo < salut | wc" | ./42sh &> log.txt
- echo "/bin/echo < salut | wc" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "/bin/echo < salut |" | ./42sh &> log.txt
- echo "/bin/echo < salut |" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "cat < cat < cat cat" | ./42sh &> log.txt
- echo "cat < cat < cat cat" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "/bin/echo > salut ; < salut cat | grep salut | > test wc -l; cat test" | ./42sh &> log.txt
- echo "/bin/echo > salut ; < salut cat | grep salut | > test wc -l; cat test" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "ls | cat -e" | ./42sh &> log.txt
- echo "ls | cat -e" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "ls | cat -e | cat -e | cat -e | cat -e" | ./42sh &> log.txt
- echo "ls | cat -e | cat -e | cat -e | cat -e" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "ls > file1 ; cat file1 ; chmod -x file1 ; cat file1" | ./42sh &> log.txt
- echo "ls > file1 ; cat file1 ; chmod -x file1 ; cat file1" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo -e "cat << EOF\naha\ntu\npue\nEOF\n" | ./42sh &> log.txt
- echo -e "cat << EOF\naha\ntu\npue\nEOF\n" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "" | ./42sh &> log.txt
- echo "" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "setenv LS= Color=12" | ./42sh &> log.txt
- echo "setenv LS= Color=12" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "./segfault" | ./42sh &> log.txt
- echo "./segfault" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "./floating" | ./42sh &> log.txt
- echo "./floating" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "unsetenv PATH ; ls" | ./42sh &> log.txt
- DIFF=$(DIFF=$(cat log.txt | grep "^ls: Command not found."))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "chmod +x Makefile ; ./Makefile ; chmod -x Makefile ; ls -l" | ./42sh &> log.txt
- DIFF=$(DIFF=$(cat log.txt | grep "^ls: Command not found."))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "man gcc | cat -e" | ./42sh &> log.txt
- echo "man gcc | cat -e" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "ls /dev | grep tty" | ./42sh &> log.txt
- echo "ls /dev | grep tty" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "ls /dev | grep tty" | ./42sh &> log.txt
- echo "ls /dev | grep tty" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "echo $PWD $HOME" | ./42sh &> log.txt
- echo "echo $PWD $HOME" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 1 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 1 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "$PWD" | ./42sh &> log.txt
- echo "$PWD" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 2 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 2 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "$ a" | ./42sh &> log.txt
- echo "$ a" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e "redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "$a" | ./42sh &> log.txt
- echo "$a" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 3 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 3 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "ls "-R" " | ./42sh &> log.txt
- echo "ls "-R" " | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 4 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 4 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "ls "$PWD" " | ./42sh &> log.txt
- echo "ls "$PWD" " | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 5 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 5 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "ls '$PWD' " | ./42sh &> log.txt
- echo "ls '$PWD' " | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 6 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 6 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo """" | ./42sh &> log.txt
- echo """" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 7 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 7 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo """" | ./42sh &> log.txt
- echo """" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 8 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 8 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo -e "foreach x (lol)" | ./42sh &> log.txt
- echo -e "foreach x (lol)" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 9 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 9 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo -e "foreach x (lol lol)\n ls" | ./42sh &> log.txt
- echo -e "foreach x (lol lol)\n ls" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 10 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 10 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo -e "foreach x (lol ( l ) lol)\n ls" | ./42sh &> log.txt
- echo -e "foreach x (lol ( l ) lol)\n ls" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 11 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 11 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo -e "foreach x (lol ( l ) lol)\n ls \n end" | ./42sh &> log.txt
- echo -e "foreach x (lol ( l ) lol)\n ls \n end" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 12 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 12 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "foreach x" | ./42sh &> log.txt
- echo "foreach x" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 13 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 13 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "foreach x (1)" | ./42sh &> log.txt
- echo "foreach x (1)" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 14 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 14 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "foreach x dsfdsf dsfsdf" | ./42sh &> log.txt
- echo "foreach x dsfdsf dsfsdf" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 15 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 15 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo -e "set a=ls \n \$a" | ./42sh &> log.txt
- echo -e "set a=ls \n \$a" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 17 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 17 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "if ( 1 == 1 ) ls" | ./42sh &> log.txt
- echo "if ( 1 == 1 ) ls" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 18 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 18 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo "if (1 == 1) ls" | ./42sh &> log.txt
- echo "if (1 == 1) ls" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 17 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 19 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo -e "if (1) ls" | ./42sh &> log.txt
- echo -e "if (1) ls" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 17 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 20 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo -e "if 1 ls" | ./42sh &> log.txt
- echo -e "if 1 ls" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 17 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 21 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo -e "if (1 == 1 ) ls" | ./42sh &> log.txt
- echo -e "if (1 == 1 ) ls" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 17 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 22 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- #Pipe2
- echo -e "if ( 1 == 1) ls" | ./42sh &> log.txt
- echo -e "if ( 1 == 1) ls" | tcsh &> tcsh.txt
- DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
- if [ "$DIFF" != "" ]; then
- echo -e " 17 redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
- ((number_of_test_sh2++))
- else {
- echo -e " 23 redirection (look .sh) test PASSED\n"
- ((test_passed++))
- ((number_of_test_sh2++))
- }
- fi
- echo "####################################"
- echo "SUCCESS TEST --> " $test_passed
- echo "NUMBER OF SH2 TEST --> " $number_of_test_sh2
- test_fail=$(echo "(44+$number_of_test_sh2)-$test_passed" |bc )
- echo "FAIL TEST --> " $test_fail
- echo "####################################"
- rm -rf log.txt
- rm -rf tcsh.txt
- rm -rf tcssh.txt
- rm file1
- rm ok
- rm salut
- rm yo
- rm -rf report
- echo -e "\n###########################END OF TESTS###########################\n"
- rm tests
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement