Advertisement
Guest User

Untitled

a guest
May 27th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 42.84 KB | None | 0 0
  1. #! /bin/bash
  2.  
  3. test_passed=0
  4. test_fail=0
  5. number_of_test_sh2=0
  6. echo -e "Integration tests by mariusvnh, zuldruck, simontraww(sh && sh2)"
  7. echo -e "\n\nGoog Luck!\n"
  8. echo -e "english version of you bash actived..\n"
  9. LANG=en_us_8859_1
  10. export LANG=en_us_8859_1
  11.  
  12. #simple exit
  13. echo "exit" | ./42sh &> log.txt
  14. if [ $? != 0 ]; then
  15.     echo -e "simple exit: Return value was $?\nExpected 0\n"
  16. else {
  17.     echo -e "simple exit: PASSED\n"
  18.     ((test_passed++))
  19. }
  20. fi
  21.  
  22. DIFF=$(diff <(cat log.txt) <(echo "exit"))
  23. if [ "$DIFF" != "" ]; then
  24.     echo -e "simple exit: Got: $DIFF\nExpected: \"\"\n"
  25. else
  26.     echo -e "simple exit [2]: PASSED\n"
  27.     ((test_passed++))
  28. fi
  29.  
  30. #exit test
  31. echo "exit 43" | ./42sh &> log.txt
  32. echo "exit 43" | tcsh &> tcssh.txt
  33.  
  34. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  35. if [ "$DIFF" != "" ]; then
  36.     echo -e "exit 43: Got: $DIFF\nExpected: \"\"\n"
  37. else {
  38.     echo -e "exit 43: PASSED\n"
  39.     ((test_passed++))
  40. }
  41. fi
  42.  
  43. #exit test
  44. echo "exit test" | ./42sh &> log.txt
  45. echo "exit test" | tcsh &> tcssh.txt
  46.  
  47. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  48. if [ "$DIFF" != "" ]; then
  49.     echo -e "exit test: Got: $DIFF\nExpected: \"\"\n"
  50. else {
  51.     echo -e "exit test: PASSED\n"
  52.     ((test_passed++))
  53. }
  54. fi
  55.  
  56. #exit 42test
  57. echo "exit 42test" | ./42sh &> log.txt
  58. echo "exit 42test" | tcsh >& tcssh.txt
  59.  
  60. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  61. if [ "$DIFF" != "" ]; then
  62.     echo -e "exit 42test: Got: $DIFF\nExpected: \"\"\n"
  63. else {
  64.     echo -e "exit 42test: PASSED\n"
  65.     ((test_passed++))
  66. }
  67. fi
  68.  
  69. #exit badly [SIMONTRAWW]
  70. echo "exit -77j" | ./42sh &> log.txt
  71. echo "exit -77j" | tcsh &> tcssh.txt
  72.  
  73. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  74. if [ "$DIFF" != "" ]; then
  75.     echo -e "exit -77j: Got: $DIFF\nExpected: \"\"\n"
  76. else {
  77.     echo -e "exit -77j: PASSED\n"
  78.     ((test_passed++))
  79. }
  80. fi
  81.  
  82. #pwd
  83. echo -e "cd ..\npwd" | ./42sh &> log.txt
  84. echo -e "cd ..\npwd" | tcsh &> tcsh.txt
  85.  
  86. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  87. if [ "$DIFF" != "" ]; then
  88.     echo -e "cd .. --> pwd: Got: $DIFF\nExpected: \"\"\n"
  89. else {
  90.     echo -e "cd .. --> pwd: PASSED\n"
  91.     ((test_passed++))
  92. }
  93. fi
  94.  
  95. #env path presence
  96. echo -e "env" | ./42sh &> log.txt
  97.  
  98. DIFF=$(cat log.txt | grep "^PATH=" | wc -l)
  99. if [ "$DIFF" != "1" ]; then
  100.     echo -e "env PATH check: Got: $DIFF\nExpected: \"1\"\n"
  101. else {
  102.     echo -e "env PATH check: PASSED\n"
  103.     ((test_passed++))
  104. }
  105. fi
  106.  
  107. #setenv
  108. echo -e "setenv SALUT PUTE\nenv" | ./42sh &> log.txt
  109.  
  110. DIFF=$(cat log.txt | grep "^SALUT=PUTE" | wc -l)
  111. if [ "$DIFF" != "1" ]; then
  112.     echo -e "setenv test: Got: $DIFF\nExpected: \"1\"\n"
  113. else {
  114.     echo -e "setenv test: PASSED\n"
  115.     ((test_passed++))
  116. }
  117. fi
  118.  
  119. #setenv
  120. echo -e "unsetenv PATH\nenv" | ./42sh &> log.txt
  121.  
  122. DIFF=$(cat log.txt | grep "^PATH" | wc -l)
  123. if [ "$DIFF" != "0" ]; then
  124.     echo -e "unsetenv test: Got: $DIFF\nExpected: \"1\"\n"
  125. else {
  126.     echo -e "unsetenv test: PASSED\n"
  127.     ((test_passed++))
  128. }
  129. fi
  130.  
  131. #setenv
  132. mkdir lstest
  133. mkdir lstest/plouplou
  134. touch lstest/salut.txt
  135. touch lstest/lala.txt
  136. touch lstest/plouplou/yop.txt
  137. cd lstest
  138.  
  139. echo -e "cd plouplou\nls" | ./../42sh &> log.txt
  140. echo -e "cd plouplou\nls" | tcsh &> tcssh.txt
  141.  
  142. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  143. if [ "$DIFF" != "" ]; then
  144.     echo -e "ls: AAAGot: $DIFF\n"
  145. else {
  146.     echo -e "ls: PASSED\n"
  147.     ((test_passed++))
  148. }
  149. fi
  150.  
  151.  
  152. #TEST LONG SPACES [SIMONTRAWW]
  153. echo "ls         " | ./../42sh &>log.txt
  154. echo "ls         " | tcsh &>tcssh.txt
  155.  
  156. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  157. if [ "$DIFF" != "" ]; then
  158.     echo -e "TEST LONG WHITESPACES : Got: $DIFF\n"
  159. else {
  160.     echo -e "TEST LONG WHITESPACES : PASSED\n"
  161.     ((test_passed++))
  162. }
  163. fi
  164.  
  165. #TEST WITH TAB [SIMONTRAWW]
  166. echo "ls        " | ./../42sh &>log.txt
  167. echo "ls        " | tcsh &>tcssh.txt
  168.  
  169. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  170. if [ "$DIFF" != "" ]; then
  171.     echo -e "TEST WITH TAB : Got: $DIFF\n"
  172. else {
  173.     echo -e "TEST WITH TAB : PASSED\n"
  174.     ((test_passed++))
  175. }
  176. fi
  177. cd ..
  178. rm -rf lstest
  179.  
  180.  
  181. #TEST WITH spaces [SIMONTRAWW]
  182. echo "cd    ../" | ./42sh &>log.txt
  183. echo "cd    ../" | tcsh &>tcssh.txt
  184.  
  185. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  186. if [ "$DIFF" != "" ]; then
  187.     echo -e "TEST CD ../ WITH SPACES : Got: $DIFF\n"
  188. else {
  189.     echo -e "TEST CD ../ WITH SPACES : PASSED\n"
  190.     ((test_passed++))
  191. }
  192. fi
  193.  
  194.  
  195.  
  196. #TEST WITH TAB [SIMONTRAWW]
  197. echo -e "\t\tcd\t" | ./42sh &>log.txt
  198. echo -e "\t\tcd\t" | tcsh &>tcssh.txt
  199.  
  200. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  201. if [ "$DIFF" != "" ]; then
  202.     echo -e "TEST CD WITH tab : Got: $DIFF\n"
  203. else {
  204.     echo -e "TEST CD WITH tab : PASSED\n"
  205.     ((test_passed++))
  206. }
  207. fi
  208.  
  209. #TEST CHMOD -x [SIMONTRAWW]
  210. touch foobar
  211. echo "echo \"fail\"" | > foobar
  212. echo -e "chmod -x ./foobar\n./foobar" |./42sh &> log.txt
  213. echo -e "chmod -x ./foobar\n./foobar" | tcsh &> tcssh.txt
  214. rm -rf foobar
  215.  
  216. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  217. if [ "$DIFF" != "" ]; then
  218.     echo -e "TEST CHMOD: Got: $DIFF\n"
  219. else {
  220.     echo -e "TEST CHMOD: PASSED\n"
  221.     ((test_passed++))
  222. }
  223. fi
  224.  
  225. #TEST ERROR + one or two letter after word [SIMONTRAWW]
  226. echo -e "exitt" | ./42sh &> log.txt
  227. echo -e "exitt" | tcsh  &> tcssh.txt
  228.  
  229. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  230. if [ "$DIFF" != "" ]; then
  231.     echo -e "TEST EXITT (one two letter at the end of word): Got: $DIFF\n"
  232. else {
  233.     echo -e "TEST EXITT (one two letter at the end of word): PASSED\n"
  234.     ((test_passed++))
  235. }
  236. fi
  237.  
  238. #TEST CHMOD +x on picture [SIMONTRAWW]
  239. wget http://convertir-une-image.com/frontframe/images/cute_ball_info.png &> /dev/null
  240. mv cute_ball_info.png test.png &> /dev/null
  241. echo -e "chmod +x test.png\n./test.png" | ./42sh &> log.txt
  242. echo -e "chmod +x test.png\n./test.png" | tcsh &> tcssh.txt
  243. rm -rf test.png
  244.  
  245. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  246. if [ "$DIFF" != "" ]; then
  247.     echo -e "TEST EXEC IMG: Got: $DIFF\n"
  248. else {
  249.     echo -e "TEST EXEC IMG: PASSED\n"
  250.     ((test_passed++))
  251. }
  252. fi
  253.  
  254. #TEST programm segfault [SIMONTRAWW]
  255. mkdir tests
  256. cd tests
  257. wget http://epi2022.fr/neo/PSU/PSU_minishell1_2017/segfault.c &> /dev/null
  258. echo -e "gcc segfault.c\n./a.out" | ./../42sh &> log.txt
  259. echo -e "gcc segfault.c\n./a.out" | tcsh &> tcssh.txt
  260. rm -rf segfault.c &> /dev/null
  261. rm -rf a.out &> /dev/null
  262.  
  263. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  264. if [ "$DIFF" != "" ]; then
  265.     echo -e "TEST SEGFAULT: Got: $DIFF\n"
  266. else {
  267.     echo -e "TEST SEGFAULT: PASSED\n"
  268.     ((test_passed++))
  269. }
  270. fi
  271.  
  272.  
  273. #TEST programm floating point exeception [SIMONTRAWW]
  274. wget http://epi2022.fr/neo/PSU/PSU_minishell1_2017/floating.c &> /dev/null
  275. echo "gcc floating.c -lm" | ./../42sh &> /dev/null
  276. echo "gcc floating.c -lm" | tcsh &> /dev/null
  277. echo -e "gcc floating.c -lm\n./a.out" | ./../42sh &> log.txt
  278. echo -e "gcc floating.c -lm\n./a.out" | tcsh &> tcssh.txt
  279. rm -rf floating.c
  280. rm -rf a.out
  281.  
  282. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  283. if [ "$DIFF" != "" ]; then
  284.     echo -e "TEST FLOATING point exception: Got: $DIFF\n"
  285. else {
  286.     echo -e "TEST FLOATING point exception: PASSED\n"
  287.     ((test_passed++))
  288. }
  289. fi
  290. cd ..
  291. rm -rf tests
  292.  
  293.  
  294. #TEST ERROR + one or two letter after word [SIMONTRAWW]
  295.  
  296. echo -e "unsetenvv" | ./42sh &> log.txt
  297. echo -e "unsetenvv" | tcsh  &> tcssh.txt
  298.  
  299. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  300. if [ "$DIFF" != "" ]; then
  301.     echo -e "TEST unsetenvv (one two letter at the end of word): Got: $DIFF\n"
  302. else {
  303.     echo -e "TEST unsetenvv (one two letter at the end of word): PASSED\n"
  304.     ((test_passed++))
  305. }
  306. fi
  307.  
  308. #TEST ERROR + one or two letter after word [SIMONTRAWW]
  309. echo -e "setenvi" | ./42sh &> log.txt
  310. echo -e "setenvi" | tcsh  &> tcssh.txt
  311.  
  312. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  313. if [ "$DIFF" != "" ]; then
  314.     echo -e "TEST setenvi (one two letter at the end of word): Got: $DIFF\n"
  315. else {
  316.     echo -e "TEST setenvi (one two letter at the end of word): PASSED\n"
  317.     ((test_passed++))
  318. }
  319. fi
  320.  
  321. #TEST cd [SIMONTRAWW]
  322. echo -e "cd\npwd" | ./42sh &>log.txt
  323. echo -e "cd\npwd" | tcsh &>tcssh.txt
  324.  
  325. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  326. if [ "$DIFF" != "" ]; then
  327.     echo -e "TEST cd : Got: $DIFF\n"
  328. else {
  329.     echo -e "TEST cd : PASSED\n"
  330.     ((test_passed++))
  331. }
  332. fi
  333.  
  334. #TEST cd ../ [SIMONTRAWW]
  335. echo -e "cd ../\npwd" | ./42sh &>log.txt
  336. echo -e "cd ../\npwd" | tcsh &>tcssh.txt
  337.  
  338. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  339. if [ "$DIFF" != "" ]; then
  340.     echo -e "TEST cd ../ : Got: $DIFF\n"
  341. else {
  342.     echo -e "TEST cd ../ : PASSED\n"
  343.     ((test_passed++))
  344. }
  345. fi
  346.  
  347. #TEST cd /dev [SIMONTRAWW]
  348. echo -e "cd /dev\npwd" | ./42sh &>log.txt
  349. echo -e "cd /dev\npwd" | tcsh &>tcssh.txt
  350.  
  351. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  352. if [ "$DIFF" != "" ]; then
  353.     echo -e "TEST cd /dev : Got: $DIFF\n"
  354. else {
  355.     echo -e "TEST cd /dev : PASSED\n"
  356.     ((test_passed++))
  357. }
  358. fi
  359.  
  360. #TEST cd NULL [SIMONTRAWW]
  361. echo -e "cd NULL" | ./42sh &>log.txt
  362. echo -e "cd NULL" | tcsh &>tcssh.txt
  363.  
  364. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  365. if [ "$DIFF" != "" ]; then
  366.     echo -e "TEST cd NULL directory : Got: $DIFF\n"
  367. else {
  368.     echo -e "TEST cd NULL directory : PASSED\n"
  369.     ((test_passed++))
  370. }
  371. fi
  372.  
  373. #TEST cd random dirr [SIMONTRAWW]
  374. echo -e "cd ../../../../../../../../\npwd" | ./42sh &>log.txt
  375. echo -e "cd ../../../../../../../../\npwd" | tcsh &>tcssh.txt
  376.  
  377. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  378. if [ "$DIFF" != "" ]; then
  379.     echo -e "TEST random dirr : Got: $DIFF\n"
  380. else {
  381.     echo -e "TEST random dirr : PASSED\n"
  382.     ((test_passed++))
  383. }
  384. fi
  385.  
  386.  
  387. #TEST cd moins without any OLDPWD [SIMONTRAWW]
  388. echo -e "cd ../\ncd -\npwd" | ./42sh &>log.txt
  389. echo -e "cd ../\ncd -\npwd" | tcsh &>tcssh.txt
  390.  
  391. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  392. if [ "$DIFF" != "" ]; then
  393.     echo -e "TEST cd moins without OLDPWD : Got: $DIFF\n"
  394. else {
  395.     echo -e "TEST cd moins without OLDPWD: PASSED\n"
  396.     ((test_passed++))
  397. }
  398. fi
  399.  
  400. #TEST NAME TOO LONG [SIMONTRAWW]
  401. echo "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  402. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | ./42sh &>log.txt ./42sh &> /dev/null
  403. echo "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  404. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | tcsh &>tcssh.txt tcsh &> /dev/null
  405.  
  406. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  407. if [ "$DIFF" != "" ]; then
  408.     echo -e "TEST CD NAME TOO LONG: Got: $DIFF\n"
  409. else {
  410.     echo -e "TEST CD NAME TOO LONG : PASSED\n"
  411.     ((test_passed++))
  412. }
  413. fi
  414.  
  415. #TEST /bin/ls [SIMONTRAWW]
  416. echo -e "/bin/ls" | ./42sh &>log.txt
  417. echo -e "/bin/ls" | tcsh &>tcssh.txt
  418.  
  419. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  420. if [ "$DIFF" != "" ]; then
  421.     echo -e "TEST /bin/ls: Got: $DIFF\n"
  422. else {
  423.     echo -e "TEST /bin/ls: PASSED\n"
  424.     ((test_passed++))
  425. }
  426. fi
  427.  
  428. #TEST /bin/ls [SIMONTRAWW]
  429. echo -e "/bin/ls" | ./42sh &>log.txt
  430. echo -e "/bin/ls" | tcsh &>tcssh.txt
  431.  
  432. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  433. if [ "$DIFF" != "" ]; then
  434.     echo -e "TEST /bin/ls: Got: $DIFF\n"
  435. else {
  436.     echo -e "TEST /bin/ls: PASSED\n"
  437.     ((test_passed++))
  438. }
  439. fi
  440.  
  441. #TEST cd bin/pwd [SIMONTRAWW]
  442. echo -e "cd /bin/pwd" | ./42sh &>log.txt
  443. echo -e  "cd /bin/pwd" | tcsh &>tcssh.txt
  444.  
  445. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  446. if [ "$DIFF" != "" ]; then
  447.     echo -e "TEST cd /bin/pwd directory : Got: $DIFF\n"
  448. else {
  449.     echo -e "TEST cd /bin/pwd directory : PASSED\n"
  450.     ((test_passed++))
  451. }
  452. fi
  453.  
  454. #setenv A 2
  455. echo -e "setenv A 2\nenv" | ./42sh &> log.txt
  456.  
  457. DIFF=$(cat log.txt | grep "^A=2" | wc -l)
  458. if [ "$DIFF" != "1" ]; then
  459.     echo -e "setenv A 2: Got: $DIFF\nExpected: \"1\"\n"
  460. else {
  461.     echo -e "setenv A 2: PASSED\n"
  462.     ((test_passed++))
  463. }
  464. fi
  465.  
  466. #TEST setenv A 2[SIMONTRAWW]
  467. echo "setenv 2 A" | ./42sh &>log.txt
  468. echo "setenv 2 A" | tcsh &>tcssh.txt
  469.  
  470. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  471. if [ "$DIFF" != "" ]; then
  472.     echo -e "SETENV 2 A error msg : Got: $DIFF\n"
  473. else {
  474.     echo -e "SETENV 2 A error msg : PASSED\n"
  475.     ((test_passed++))
  476. }
  477. fi
  478.  
  479. #TEST setenv A/ 2[SIMONTRAWW]
  480. echo "setenv A/ 2" | ./42sh &>log.txt
  481. echo "setenv A/ 2" | tcsh &>tcssh.txt
  482.  
  483. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  484. if [ "$DIFF" != "" ]; then
  485.     echo -e "SETENV A/ 2 error msg : Got: $DIFF\n"
  486. else {
  487.     echo -e "SETENV A/ 2 error msg : PASSED\n"
  488.     ((test_passed++))
  489. }
  490. fi
  491.  
  492. #TEST setenv A 2[SIMONTRAWW]
  493. echo "setenv SALU/T 2" | ./42sh &>log.txt
  494. echo "setenv SALU/T 2" | tcsh &>tcssh.txt
  495.  
  496. DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
  497. if [ "$DIFF" != "" ]; then
  498.     echo -e "SETENV SALU/T 2 error msg : Got: $DIFF\n"
  499. else {
  500.     echo -e "SETENV SALU/T 2 error msg : PASSED\n"
  501.     ((test_passed++))
  502. }
  503. fi
  504.  
  505. #CD cd -
  506. echo -e "cd ..\ncd -\npwd" | ./42sh &> log.txt
  507. echo -e "cd ..\ncd -\npwd" | tcsh &> tcsh.txt
  508.  
  509. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  510. if [ "$DIFF" != "" ]; then
  511.     echo -e "cd .. puis cd - puis pwd --> pwd: Got: $DIFF\nExpected: \"\"\n"
  512. else {
  513.     echo -e "cd .. puis cd - puis pwd -->  pwd: PASSED\n"
  514.     ((test_passed++))
  515. }
  516. fi
  517.  
  518. #CD cd -
  519. echo -e "cd ..\ncd -\ncd ../\ncd -\ncd ../\ncd -\npwd" | ./42sh &> log.txt
  520. echo -e "cd ..\ncd -\ncd ../\ncd -\ncd ../\ncd -\npwd" | tcsh &> tcsh.txt
  521.  
  522. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  523. if [ "$DIFF" != "" ]; then
  524.     echo -e "cd .. puis cd - puis cd ../ puis cd - (3fois) puis pwd --> pwd: Got: $DIFF\nExpected: \"\"\n"
  525. else {
  526.     echo -e "cd .. puis cd - puis cd ../ puis cd - (3fois) puis pwd -->  pwd: PASSED\n"
  527.     ((test_passed++))
  528. }
  529. fi
  530.  
  531. #CD cd -
  532. echo -e "cd ..\ncd -\ncd ../\ncd -\ncd ../\ncd -\npwd" | ./42sh &> log.txt
  533. echo -e "cd ..\ncd -\ncd ../\ncd -\ncd ../\ncd -\npwd" | tcsh &> tcsh.txt
  534.  
  535. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  536. if [ "$DIFF" != "" ]; then
  537.     echo -e "cd .. puis cd - puis cd ../ puis cd - (3fois) puis pwd --> pwd: Got: $DIFF\nExpected: \"\"\n"
  538. else {
  539.     echo -e "cd .. puis cd - puis cd ../ puis cd - (3fois) puis pwd -->  pwd: PASSED\n"
  540.     ((test_passed++))
  541. }
  542. fi
  543.  
  544. #CD cd -
  545. echo "setenv 2/A" | ./42sh &> log.txt
  546. echo "setenv 2/A" | tcsh &> tcsh.txt
  547.  
  548. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  549. if [ "$DIFF" != "" ]; then
  550.     echo -e "setenv 2/A --> pwd: Got: $DIFF\nExpected: \"\"\n"
  551. else {
  552.     echo -e "setenv 2/A -->  pwd: PASSED\n"
  553.     ((test_passed++))
  554. }
  555. fi
  556.  
  557. #Pipe2
  558. echo "/bin/echo salut |cat|wc -l" | ./42sh &> log.txt
  559. echo "/bin/echo salut |cat|wc -l" | tcsh &> tcsh.txt
  560.  
  561. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  562. if [ "$DIFF" != "" ]; then
  563.     echo -e "Pipe2 --> Pipe2: Got: $DIFF\nExpected: \"\"\n"
  564. else {
  565.     echo -e "Pipe2 -->  Pipe2: PASSED\n"
  566.     ((test_passed++))
  567. }
  568. fi
  569.  
  570. #Pipe2
  571. echo "env | grep PWD" | ./42sh &> log.txt
  572. echo "env | grep PWD" | tcsh &> tcsh.txt
  573.  
  574. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  575. if [ "$DIFF" != "" ]; then
  576.     echo -e "Pipe Builtin --> pipe builtin: Got: $DIFF\nExpected: \"\"\n"
  577. else {
  578.     echo -e "Pipe Builtin  -->  pipe builtin: PASSED\n"
  579.     ((test_passed++))
  580. }
  581. fi
  582.  
  583. #Pipe2
  584. echo "unsetenv PWD ; env | grep PWD" | ./42sh &> log.txt
  585. echo "unsetenv PWD ; env | grep PWD" | tcsh &> tcsh.txt
  586.  
  587. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  588. if [ "$DIFF" != "" ]; then
  589.     echo -e "unsetenv PWD ; env | grep PWD --> pipe builtin: Got: $DIFF\nExpected: \"\"\n"
  590. else {
  591.     echo -e "unsetenv PWD ; env | grep PWD  -->  pipe builtin: PASSED\n"
  592.     ((test_passed++))
  593. }
  594. fi
  595.  
  596. #Pipe2
  597. echo "setenv | grep PWD" | ./42sh &> log.txt
  598. echo "setenv | grep PWD" | tcsh &> tcsh.txt
  599.  
  600. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  601.  
  602. if [ "$DIFF" != "" ]; then
  603.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  604.     ((number_of_test_sh2++))
  605. else {
  606.     echo -e "redirection (look .sh) test PASSED\n"
  607.     ((test_passed++))
  608.     ((number_of_test_sh2++))
  609. }
  610. fi
  611.  
  612. #Pipe2
  613. echo "cd trololol | cat -e" | ./42sh &> log.txt
  614. echo "cd trololol | cat -e" | tcsh &> tcsh.txt
  615.  
  616. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  617.  
  618. if [ "$DIFF" != "" ]; then
  619.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  620.     ((number_of_test_sh2++))
  621. else {
  622.     echo -e "redirection (look .sh) test PASSED\n"
  623.     ((test_passed++))
  624.     ((number_of_test_sh2++))
  625. }
  626. fi
  627.  
  628. #Pipe2
  629. echo "exit 42 | /bin/echo coucou" | ./42sh &> log.txt
  630. echo "exit 42 | /bin/echo coucou" | tcsh &> tcsh.txt
  631.  
  632. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  633.  
  634. if [ "$DIFF" != "" ]; then
  635.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  636.     ((number_of_test_sh2++))
  637. else {
  638.     echo -e "redirection (look .sh) test PASSED\n"
  639.     ((test_passed++))
  640.     ((number_of_test_sh2++))
  641. }
  642. fi
  643.  
  644. #Pipe2
  645. echo "/bin/echo bonjour |" | ./42sh &> log.txt
  646. echo "/bin/echo bonjour |" | tcsh &> tcsh.txt
  647.  
  648. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  649.  
  650. if [ "$DIFF" != "" ]; then
  651.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  652.     ((number_of_test_sh2++))
  653. else {
  654.     echo -e "redirection (look .sh) test PASSED\n"
  655.     ((test_passed++))
  656.     ((number_of_test_sh2++))
  657. }
  658. fi
  659.  
  660. #Pipe2
  661. echo "cat < superfile | cat -e > salut ; cat salut -e" | ./42sh &> log.txt
  662. echo "cat < superfile | cat -e > salut ; cat salut -e" | tcsh &> tcsh.txt
  663.  
  664. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  665.  
  666. if [ "$DIFF" != "" ]; then
  667.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  668.     ((number_of_test_sh2++))
  669. else {
  670.     echo -e "redirection (look .sh) test PASSED\n"
  671.     ((test_passed++))
  672.     ((number_of_test_sh2++))
  673. }
  674. fi
  675.  
  676. #Pipe2
  677. echo "ls << /bin | cat -e > /dev/null < ls" | ./42sh &> log.txt
  678. echo "ls << /bin | cat -e > /dev/null < ls" | tcsh &> tcsh.txt
  679.  
  680. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  681.  
  682. if [ "$DIFF" != "" ]; then
  683.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  684.     ((number_of_test_sh2++))
  685. else {
  686.     echo -e "redirection (look .sh) test PASSED\n"
  687.     ((test_passed++))
  688.     ((number_of_test_sh2++))
  689. }
  690. fi
  691.  
  692. #Pipe2
  693. echo "||| /bin/echo bonjour |||||" | ./42sh &> log.txt
  694. echo "||| /bin/echo bonjour |||||" | tcsh &> tcsh.txt
  695.  
  696. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  697.  
  698. if [ "$DIFF" != "" ]; then
  699.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  700.     ((number_of_test_sh2++))
  701. else {
  702.     echo -e "redirection (look .sh) test PASSED\n"
  703.     ((test_passed++))
  704.     ((number_of_test_sh2++))
  705. }
  706. fi
  707.  
  708. #Pipe2
  709. echo "/bin/echo | bonjour" | ./42sh &> log.txt
  710. echo "/bin/echo | bonjour" | tcsh &> tcsh.txt
  711.  
  712. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  713.  
  714. if [ "$DIFF" != "" ]; then
  715.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  716.     ((number_of_test_sh2++))
  717. else {
  718.     echo -e "redirection (look .sh) test PASSED\n"
  719.     ((test_passed++))
  720.     ((number_of_test_sh2++))
  721. }
  722. fi
  723.  
  724. #Pipe2
  725. echo "/bin/echo | bonjour |" | ./42sh &> log.txt
  726. echo "/bin/echo | bonjour |" | tcsh &> tcsh.txt
  727.  
  728. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  729.  
  730. if [ "$DIFF" != "" ]; then
  731.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  732.     ((number_of_test_sh2++))
  733. else {
  734.     echo -e "redirection (look .sh) test PASSED\n"
  735.     ((test_passed++))
  736.     ((number_of_test_sh2++))
  737. }
  738. fi
  739.  
  740. #Pipe2
  741. echo "> file env \n cat file | grep PWD" | ./42sh &> log.txt
  742. echo "> file env \n cat file | grep PWD" | tcsh &> tcsh.txt
  743.  
  744. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  745.  
  746. if [ "$DIFF" != "" ]; then
  747.     echo -e "redirection EXOTIC(look .sh): Got: $DIFF\nExpected: \"\"\n"
  748.     ((number_of_test_sh2++))
  749. else {
  750.     echo -e "redirection EXOTIC(look .sh) test PASSED\n"
  751.     ((test_passed++))
  752.     ((number_of_test_sh2++))
  753. }
  754. fi
  755.  
  756. #Pipe2
  757. echo "|" | ./42sh &> log.txt
  758. echo "|" | tcsh &> tcsh.txt
  759.  
  760. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  761.  
  762. if [ "$DIFF" != "" ]; then
  763.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  764.     ((number_of_test_sh2++))
  765. else {
  766.     echo -e "redirection (look .sh) test PASSED\n"
  767.     ((test_passed++))
  768.     ((number_of_test_sh2++))
  769. }
  770. fi
  771.  
  772.  
  773. #Pipe2
  774. echo "<|" | ./42sh &> log.txt
  775. echo "<|" | tcsh &> tcsh.txt
  776.  
  777. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  778.  
  779. if [ "$DIFF" != "" ]; then
  780.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  781.     ((number_of_test_sh2++))
  782. else {
  783.     echo -e "redirection (look .sh) test PASSED\n"
  784.     ((test_passed++))
  785.     ((number_of_test_sh2++))
  786. }
  787. fi
  788.  
  789. #Pipe2
  790. echo "/bin/echo > |" | ./42sh &> log.txt
  791. echo "/bin/echo > |" | tcsh &> tcsh.txt
  792.  
  793. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  794.  
  795. if [ "$DIFF" != "" ]; then
  796.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  797.     ((number_of_test_sh2++))
  798. else {
  799.     echo -e "redirection (look .sh) test PASSED\n"
  800.     ((test_passed++))
  801.     ((number_of_test_sh2++))
  802. }
  803. fi
  804.  
  805. #Pipe2
  806. echo ">> /bin/echo >>" | ./42sh &> log.txt
  807. echo ">> /bin/echo >>" | tcsh &> tcsh.txt
  808.  
  809. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  810.  
  811. if [ "$DIFF" != "" ]; then
  812.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  813.     ((number_of_test_sh2++))
  814. else {
  815.     echo -e "redirection (look .sh) test PASSED\n"
  816.     ((test_passed++))
  817.     ((number_of_test_sh2++))
  818. }
  819. fi
  820.  
  821. #Pipe2
  822. echo "| cat >> /bin/echo << >> << |" | ./42sh &> log.txt
  823. echo "| cat >> /bin/echo << >> << |" | tcsh &> tcsh.txt
  824.  
  825. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  826.  
  827. if [ "$DIFF" != "" ]; then
  828.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  829.     ((number_of_test_sh2++))
  830. else {
  831.     echo -e "redirection (look .sh) test PASSED\n"
  832.     ((test_passed++))
  833.     ((number_of_test_sh2++))
  834. }
  835. fi
  836.  
  837. #Pipe2
  838. echo "ls | cat < ok" | ./42sh &> log.txt
  839. echo "ls | cat < ok" | tcsh &> tcsh.txt
  840.  
  841. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  842.  
  843. if [ "$DIFF" != "" ]; then
  844.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  845.     ((number_of_test_sh2++))
  846. else {
  847.     echo -e "redirection (look .sh) test PASSED\n"
  848.     ((test_passed++))
  849.     ((number_of_test_sh2++))
  850. }
  851. fi
  852.  
  853. #Pipe2
  854. echo "ls > ok | cat" | ./42sh &> log.txt
  855. echo "ls > ok | cat" | tcsh &> tcsh.txt
  856.  
  857. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  858.  
  859. if [ "$DIFF" != "" ]; then
  860.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  861.     ((number_of_test_sh2++))
  862. else {
  863.     echo -e "redirection (look .sh) test PASSED\n"
  864.     ((test_passed++))
  865.     ((number_of_test_sh2++))
  866. }
  867. fi
  868.  
  869. #Pipe2
  870. echo "ls > ok | cat < lol" | ./42sh &> log.txt
  871. echo "ls > ok | cat < lol" | tcsh &> tcsh.txt
  872.  
  873. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  874.  
  875. if [ "$DIFF" != "" ]; then
  876.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  877.     ((number_of_test_sh2++))
  878. else {
  879.     echo -e "redirection (look .sh) test PASSED\n"
  880.     ((test_passed++))
  881.     ((number_of_test_sh2++))
  882. }
  883. fi
  884.  
  885. #Pipe2
  886. echo "ls / | cat > ok ; cat ok" | ./42sh &> log.txt
  887. echo "ls / | cat > ok ; cat ok" | tcsh &> tcsh.txt
  888.  
  889. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  890.  
  891. if [ "$DIFF" != "" ]; then
  892.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  893.     ((number_of_test_sh2++))
  894. else {
  895.     echo -e "redirection (look .sh) test PASSED\n"
  896.     ((test_passed++))
  897.     ((number_of_test_sh2++))
  898. }
  899. fi
  900.  
  901. #Pipe2
  902. echo "ls / | cat | cat -e | cat > ok ; cat ok" | ./42sh &> log.txt
  903. echo "ls / | cat | cat -e | cat > ok ; cat ok" | tcsh &> tcsh.txt
  904.  
  905. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  906.  
  907. if [ "$DIFF" != "" ]; then
  908.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  909.     ((number_of_test_sh2++))
  910. else {
  911.     echo -e "redirection (look .sh) test PASSED\n"
  912.     ((test_passed++))
  913.     ((number_of_test_sh2++))
  914. }
  915. fi
  916.  
  917. #Pipe2
  918. echo "cat < superfile | cat -e" | ./42sh &> log.txt
  919. echo "cat < superfile | cat -e" | tcsh &> tcsh.txt
  920.  
  921. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  922.  
  923. if [ "$DIFF" != "" ]; then
  924.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  925.     ((number_of_test_sh2++))
  926. else {
  927.     echo -e "redirection (look .sh) test PASSED\n"
  928.     ((test_passed++))
  929.     ((number_of_test_sh2++))
  930. }
  931. fi
  932.  
  933.  
  934. #Pipe2
  935. echo "ls > file < 42; cat file" | ./42sh &> log.txt
  936. echo "ls > file < 42; cat file" | tcsh &> tcsh.txt
  937.  
  938. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  939.  
  940. if [ "$DIFF" != "" ]; then
  941.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  942.     ((number_of_test_sh2++))
  943. else {
  944.     echo -e "redirection (look .sh) test PASSED\n"
  945.     ((test_passed++))
  946.     ((number_of_test_sh2++))
  947. }
  948. fi
  949.  
  950. #Pipe2
  951. echo "/bin/echo bonjour < salut test > yo   ;    cat yo" | ./42sh &> log.txt
  952. echo "/bin/echo bonjour < salut test > yo   ;    cat yo" | tcsh &> tcsh.txt
  953.  
  954. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  955.  
  956. if [ "$DIFF" != "" ]; then
  957.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  958.     ((number_of_test_sh2++))
  959. else {
  960.     echo -e "redirection (look .sh) test PASSED\n"
  961.     ((test_passed++))
  962.     ((number_of_test_sh2++))
  963. }
  964. fi
  965.  
  966. #Pipe2
  967. echo "/bin/echo | cat | cat | cat | wc" | ./42sh &> log.txt
  968. echo "/bin/echo | cat | cat | cat | wc" | tcsh &> tcsh.txt
  969.  
  970. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  971.  
  972. if [ "$DIFF" != "" ]; then
  973.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  974.     ((number_of_test_sh2++))
  975. else {
  976.     echo -e "redirection (look .sh) test PASSED\n"
  977.     ((test_passed++))
  978.     ((number_of_test_sh2++))
  979. }
  980. fi
  981.  
  982. #Pipe2
  983. echo "/bin/echo >> salut >> salut" | ./42sh &> log.txt
  984. echo "/bin/echo >> salut >> salut" | tcsh &> tcsh.txt
  985.  
  986. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  987.  
  988. if [ "$DIFF" != "" ]; then
  989.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  990.     ((number_of_test_sh2++))
  991. else {
  992.     echo -e "redirection (look .sh) test PASSED\n"
  993.     ((test_passed++))
  994.     ((number_of_test_sh2++))
  995. }
  996. fi
  997.  
  998. #Pipe2
  999. echo "/bin/echo >> salut >> salut" | ./42sh &> log.txt
  1000. echo "/bin/echo >> salut >> salut" | tcsh &> tcsh.txt
  1001.  
  1002. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1003.  
  1004. if [ "$DIFF" != "" ]; then
  1005.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1006.     ((number_of_test_sh2++))
  1007. else {
  1008.     echo -e "redirection (look .sh) test PASSED\n"
  1009.     ((test_passed++))
  1010.     ((number_of_test_sh2++))
  1011. }
  1012. fi
  1013.  
  1014. #Pipe2
  1015. echo "/bin/echo bonjour > salut; /bin/echo bonjour >> salut; cat -e < salut | cat" | ./42sh &> log.txt
  1016. echo "/bin/echo bonjour > salut; /bin/echo bonjour >> salut; cat -e < salut | cat" | tcsh &> tcsh.txt
  1017.  
  1018. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1019.  
  1020. if [ "$DIFF" != "" ]; then
  1021.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1022.     ((number_of_test_sh2++))
  1023. else {
  1024.     echo -e "redirection (look .sh) test PASSED\n"
  1025.     ((test_passed++))
  1026.     ((number_of_test_sh2++))
  1027. }
  1028. fi
  1029.  
  1030. #Pipe2
  1031. echo "/bin/echo bonjour > salut; /bin/echo bonjour >> salut; cat -e < salut | cat" | ./42sh &> log.txt
  1032. echo "/bin/echo bonjour > salut; /bin/echo bonjour >> salut; cat -e < salut | cat" | tcsh &> tcsh.txt
  1033.  
  1034. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1035.  
  1036. if [ "$DIFF" != "" ]; then
  1037.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1038.     ((number_of_test_sh2++))
  1039. else {
  1040.     echo -e "redirection (look .sh) test PASSED\n"
  1041.     ((test_passed++))
  1042.     ((number_of_test_sh2++))
  1043. }
  1044. fi
  1045.  
  1046. #Pipe2
  1047. echo "/bin/echo > salut | wc" | ./42sh &> log.txt
  1048. echo "/bin/echo > salut | wc" | tcsh &> tcsh.txt
  1049.  
  1050. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1051.  
  1052. if [ "$DIFF" != "" ]; then
  1053.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1054.     ((number_of_test_sh2++))
  1055. else {
  1056.     echo -e "redirection (look .sh) test PASSED\n"
  1057.     ((test_passed++))
  1058.     ((number_of_test_sh2++))
  1059. }
  1060. fi
  1061.  
  1062. #Pipe2
  1063. echo "/bin/echo < salut | wc" | ./42sh &> log.txt
  1064. echo "/bin/echo < salut | wc" | tcsh &> tcsh.txt
  1065.  
  1066. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1067.  
  1068. if [ "$DIFF" != "" ]; then
  1069.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1070.     ((number_of_test_sh2++))
  1071. else {
  1072.     echo -e "redirection (look .sh) test PASSED\n"
  1073.     ((test_passed++))
  1074.     ((number_of_test_sh2++))
  1075. }
  1076. fi
  1077.  
  1078. #Pipe2
  1079. echo "/bin/echo < salut |" | ./42sh &> log.txt
  1080. echo "/bin/echo < salut |" | tcsh &> tcsh.txt
  1081.  
  1082. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1083.  
  1084. if [ "$DIFF" != "" ]; then
  1085.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1086.     ((number_of_test_sh2++))
  1087. else {
  1088.     echo -e "redirection (look .sh) test PASSED\n"
  1089.     ((test_passed++))
  1090.     ((number_of_test_sh2++))
  1091. }
  1092. fi
  1093.  
  1094. #Pipe2
  1095. echo "cat < cat < cat cat" | ./42sh &> log.txt
  1096. echo "cat < cat < cat cat" | tcsh &> tcsh.txt
  1097.  
  1098. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1099.  
  1100. if [ "$DIFF" != "" ]; then
  1101.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1102.     ((number_of_test_sh2++))
  1103. else {
  1104.     echo -e "redirection (look .sh) test PASSED\n"
  1105.     ((test_passed++))
  1106.     ((number_of_test_sh2++))
  1107. }
  1108. fi
  1109.  
  1110.  
  1111. #Pipe2
  1112. echo "/bin/echo > salut ; < salut cat | grep salut | > test wc -l; cat test" | ./42sh &> log.txt
  1113. echo "/bin/echo > salut ; < salut cat | grep salut | > test wc -l; cat test" | tcsh &> tcsh.txt
  1114.  
  1115. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1116.  
  1117. if [ "$DIFF" != "" ]; then
  1118.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1119.     ((number_of_test_sh2++))
  1120. else {
  1121.     echo -e "redirection (look .sh) test PASSED\n"
  1122.     ((test_passed++))
  1123.     ((number_of_test_sh2++))
  1124. }
  1125. fi
  1126.  
  1127. #Pipe2
  1128. echo "ls | cat -e" | ./42sh &> log.txt
  1129. echo "ls | cat -e" | tcsh &> tcsh.txt
  1130.  
  1131. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1132.  
  1133. if [ "$DIFF" != "" ]; then
  1134.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1135.     ((number_of_test_sh2++))
  1136. else {
  1137.     echo -e "redirection (look .sh) test PASSED\n"
  1138.     ((test_passed++))
  1139.     ((number_of_test_sh2++))
  1140. }
  1141. fi
  1142.  
  1143. #Pipe2
  1144. echo "ls | cat -e | cat -e | cat -e | cat -e" | ./42sh &> log.txt
  1145. echo "ls | cat -e | cat -e | cat -e | cat -e" | tcsh &> tcsh.txt
  1146.  
  1147. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1148.  
  1149. if [ "$DIFF" != "" ]; then
  1150.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1151.     ((number_of_test_sh2++))
  1152. else {
  1153.     echo -e "redirection (look .sh) test PASSED\n"
  1154.     ((test_passed++))
  1155.     ((number_of_test_sh2++))
  1156. }
  1157. fi
  1158.  
  1159. #Pipe2
  1160. echo "ls > file1 ; cat file1 ; chmod -x file1 ; cat file1" | ./42sh &> log.txt
  1161. echo "ls > file1 ; cat file1 ; chmod -x file1 ; cat file1" | tcsh &> tcsh.txt
  1162.  
  1163. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1164.  
  1165. if [ "$DIFF" != "" ]; then
  1166.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1167.     ((number_of_test_sh2++))
  1168. else {
  1169.     echo -e "redirection (look .sh) test PASSED\n"
  1170.     ((test_passed++))
  1171.     ((number_of_test_sh2++))
  1172. }
  1173. fi
  1174.  
  1175. #Pipe2
  1176. echo -e "cat << EOF\naha\ntu\npue\nEOF\n" | ./42sh &> log.txt
  1177. echo -e "cat << EOF\naha\ntu\npue\nEOF\n" | tcsh &> tcsh.txt
  1178.  
  1179. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1180.  
  1181. if [ "$DIFF" != "" ]; then
  1182.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1183.     ((number_of_test_sh2++))
  1184. else {
  1185.     echo -e "redirection (look .sh) test PASSED\n"
  1186.     ((test_passed++))
  1187.     ((number_of_test_sh2++))
  1188. }
  1189. fi
  1190.  
  1191. #Pipe2
  1192. echo "" | ./42sh &> log.txt
  1193. echo "" | tcsh &> tcsh.txt
  1194.  
  1195. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1196.  
  1197. if [ "$DIFF" != "" ]; then
  1198.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1199.     ((number_of_test_sh2++))
  1200. else {
  1201.     echo -e "redirection (look .sh) test PASSED\n"
  1202.     ((test_passed++))
  1203.     ((number_of_test_sh2++))
  1204. }
  1205. fi
  1206.  
  1207. #Pipe2
  1208. echo "setenv LS= Color=12" | ./42sh &> log.txt
  1209. echo "setenv LS= Color=12" | tcsh &> tcsh.txt
  1210.  
  1211. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1212.  
  1213. if [ "$DIFF" != "" ]; then
  1214.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1215.     ((number_of_test_sh2++))
  1216. else {
  1217.     echo -e "redirection (look .sh) test PASSED\n"
  1218.     ((test_passed++))
  1219.     ((number_of_test_sh2++))
  1220. }
  1221. fi
  1222.  
  1223. #Pipe2
  1224. echo "./segfault" | ./42sh &> log.txt
  1225. echo "./segfault" | tcsh &> tcsh.txt
  1226.  
  1227. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1228.  
  1229. if [ "$DIFF" != "" ]; then
  1230.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1231.     ((number_of_test_sh2++))
  1232. else {
  1233.     echo -e "redirection (look .sh) test PASSED\n"
  1234.     ((test_passed++))
  1235.     ((number_of_test_sh2++))
  1236. }
  1237. fi
  1238.  
  1239. #Pipe2
  1240. echo "./floating" | ./42sh &> log.txt
  1241. echo "./floating" | tcsh &> tcsh.txt
  1242.  
  1243. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1244.  
  1245. if [ "$DIFF" != "" ]; then
  1246.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1247.     ((number_of_test_sh2++))
  1248. else {
  1249.     echo -e "redirection (look .sh) test PASSED\n"
  1250.     ((test_passed++))
  1251.     ((number_of_test_sh2++))
  1252. }
  1253. fi
  1254.  
  1255. #Pipe2
  1256. echo "unsetenv PATH ; ls" | ./42sh &> log.txt
  1257.  
  1258. DIFF=$(DIFF=$(cat log.txt | grep "^ls: Command not found."))
  1259.  
  1260. if [ "$DIFF" != "" ]; then
  1261.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1262.     ((number_of_test_sh2++))
  1263. else {
  1264.     echo -e "redirection (look .sh) test PASSED\n"
  1265.     ((test_passed++))
  1266.     ((number_of_test_sh2++))
  1267. }
  1268. fi
  1269.  
  1270. #Pipe2
  1271. echo "chmod +x Makefile ; ./Makefile ; chmod -x Makefile ; ls -l" | ./42sh &> log.txt
  1272.  
  1273. DIFF=$(DIFF=$(cat log.txt | grep "^ls: Command not found."))
  1274.  
  1275. if [ "$DIFF" != "" ]; then
  1276.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1277.     ((number_of_test_sh2++))
  1278. else {
  1279.     echo -e "redirection (look .sh) test PASSED\n"
  1280.     ((test_passed++))
  1281.     ((number_of_test_sh2++))
  1282. }
  1283. fi
  1284.  
  1285. #Pipe2
  1286. echo "man gcc | cat -e" | ./42sh &> log.txt
  1287. echo "man gcc | cat -e" | tcsh &> tcsh.txt
  1288.  
  1289. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1290.  
  1291. if [ "$DIFF" != "" ]; then
  1292.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1293.     ((number_of_test_sh2++))
  1294. else {
  1295.     echo -e "redirection (look .sh) test PASSED\n"
  1296.     ((test_passed++))
  1297.     ((number_of_test_sh2++))
  1298. }
  1299. fi
  1300.  
  1301. #Pipe2
  1302. echo "ls /dev | grep tty" | ./42sh &> log.txt
  1303. echo "ls /dev | grep tty" | tcsh &> tcsh.txt
  1304.  
  1305. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1306.  
  1307. if [ "$DIFF" != "" ]; then
  1308.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1309.     ((number_of_test_sh2++))
  1310. else {
  1311.     echo -e "redirection (look .sh) test PASSED\n"
  1312.     ((test_passed++))
  1313.     ((number_of_test_sh2++))
  1314. }
  1315. fi
  1316.  
  1317. #Pipe2
  1318. echo "ls /dev | grep tty" | ./42sh &> log.txt
  1319. echo "ls /dev | grep tty" | tcsh &> tcsh.txt
  1320.  
  1321. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1322.  
  1323. if [ "$DIFF" != "" ]; then
  1324.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1325.     ((number_of_test_sh2++))
  1326. else {
  1327.     echo -e "redirection (look .sh) test PASSED\n"
  1328.     ((test_passed++))
  1329.     ((number_of_test_sh2++))
  1330. }
  1331. fi
  1332.  
  1333.  
  1334. #Pipe2
  1335. echo "echo $PWD $HOME" | ./42sh &> log.txt
  1336. echo "echo $PWD $HOME" | tcsh &> tcsh.txt
  1337.  
  1338. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1339.  
  1340. if [ "$DIFF" != "" ]; then
  1341.     echo -e " 1   redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1342.     ((number_of_test_sh2++))
  1343. else {
  1344.     echo -e " 1    redirection (look .sh) test PASSED\n"
  1345.     ((test_passed++))
  1346.     ((number_of_test_sh2++))
  1347. }
  1348. fi
  1349.  
  1350. #Pipe2
  1351. echo "$PWD" | ./42sh &> log.txt
  1352. echo "$PWD" | tcsh &> tcsh.txt
  1353.  
  1354. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1355.  
  1356. if [ "$DIFF" != "" ]; then
  1357.     echo -e "  2  redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1358.     ((number_of_test_sh2++))
  1359. else {
  1360.     echo -e " 2  redirection (look .sh) test PASSED\n"
  1361.     ((test_passed++))
  1362.     ((number_of_test_sh2++))
  1363. }
  1364. fi
  1365.  
  1366. #Pipe2
  1367. echo "$ a" | ./42sh &> log.txt
  1368. echo "$ a" | tcsh &> tcsh.txt
  1369.  
  1370. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1371.  
  1372. if [ "$DIFF" != "" ]; then
  1373.     echo -e "redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1374.     ((number_of_test_sh2++))
  1375. else {
  1376.     echo -e "redirection (look .sh) test PASSED\n"
  1377.     ((test_passed++))
  1378.     ((number_of_test_sh2++))
  1379. }
  1380. fi
  1381.  
  1382. #Pipe2
  1383. echo "$a" | ./42sh &> log.txt
  1384. echo "$a" | tcsh &> tcsh.txt
  1385.  
  1386. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1387.  
  1388. if [ "$DIFF" != "" ]; then
  1389.     echo -e " 3   redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1390.     ((number_of_test_sh2++))
  1391. else {
  1392.     echo -e "  3  redirection (look .sh) test PASSED\n"
  1393.     ((test_passed++))
  1394.     ((number_of_test_sh2++))
  1395. }
  1396. fi
  1397.  
  1398. #Pipe2
  1399. echo "ls "-R" " | ./42sh &> log.txt
  1400. echo "ls "-R" " | tcsh &> tcsh.txt
  1401.  
  1402. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1403.  
  1404. if [ "$DIFF" != "" ]; then
  1405.     echo -e "  4  redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1406.     ((number_of_test_sh2++))
  1407. else {
  1408.     echo -e "  4  redirection (look .sh) test PASSED\n"
  1409.     ((test_passed++))
  1410.     ((number_of_test_sh2++))
  1411. }
  1412. fi
  1413.  
  1414. #Pipe2
  1415. echo "ls "$PWD" " | ./42sh &> log.txt
  1416. echo "ls "$PWD" " | tcsh &> tcsh.txt
  1417.  
  1418. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1419.  
  1420. if [ "$DIFF" != "" ]; then
  1421.     echo -e "  5  redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1422.     ((number_of_test_sh2++))
  1423. else {
  1424.     echo -e "  5  redirection (look .sh) test PASSED\n"
  1425.     ((test_passed++))
  1426.     ((number_of_test_sh2++))
  1427. }
  1428. fi
  1429.  
  1430. #Pipe2
  1431. echo "ls '$PWD' " | ./42sh &> log.txt
  1432. echo "ls '$PWD' " | tcsh &> tcsh.txt
  1433.  
  1434. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1435.  
  1436. if [ "$DIFF" != "" ]; then
  1437.     echo -e "  6  redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1438.     ((number_of_test_sh2++))
  1439. else {
  1440.     echo -e "  6  redirection (look .sh) test PASSED\n"
  1441.     ((test_passed++))
  1442.     ((number_of_test_sh2++))
  1443. }
  1444. fi
  1445.  
  1446.  
  1447. #Pipe2
  1448. echo """" | ./42sh &> log.txt
  1449. echo """" | tcsh &> tcsh.txt
  1450.  
  1451. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1452.  
  1453. if [ "$DIFF" != "" ]; then
  1454.     echo -e "  7  redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1455.     ((number_of_test_sh2++))
  1456. else {
  1457.     echo -e "   7  redirection (look .sh) test PASSED\n"
  1458.     ((test_passed++))
  1459.     ((number_of_test_sh2++))
  1460. }
  1461. fi
  1462.  
  1463.  
  1464. #Pipe2
  1465. echo """" | ./42sh &> log.txt
  1466. echo """" | tcsh &> tcsh.txt
  1467.  
  1468. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1469.  
  1470. if [ "$DIFF" != "" ]; then
  1471.     echo -e "   8  redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1472.     ((number_of_test_sh2++))
  1473. else {
  1474.     echo -e "    8  redirection (look .sh) test PASSED\n"
  1475.     ((test_passed++))
  1476.     ((number_of_test_sh2++))
  1477. }
  1478. fi
  1479.  
  1480.  
  1481. #Pipe2
  1482. echo -e "foreach x (lol)" | ./42sh &> log.txt
  1483. echo -e "foreach x (lol)" | tcsh &> tcsh.txt
  1484.  
  1485. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1486.  
  1487. if [ "$DIFF" != "" ]; then
  1488.     echo -e "   9   redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1489.     ((number_of_test_sh2++))
  1490. else {
  1491.     echo -e "   9   redirection (look .sh) test PASSED\n"
  1492.     ((test_passed++))
  1493.     ((number_of_test_sh2++))
  1494. }
  1495. fi
  1496.  
  1497. #Pipe2
  1498. echo -e "foreach x (lol lol)\n ls" | ./42sh &> log.txt
  1499. echo -e "foreach x (lol lol)\n ls" | tcsh &> tcsh.txt
  1500.  
  1501. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1502.  
  1503. if [ "$DIFF" != "" ]; then
  1504.     echo -e "   10   redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1505.     ((number_of_test_sh2++))
  1506. else {
  1507.     echo -e "   10   redirection (look .sh) test PASSED\n"
  1508.     ((test_passed++))
  1509.     ((number_of_test_sh2++))
  1510. }
  1511. fi
  1512.  
  1513. #Pipe2
  1514. echo -e "foreach x (lol ( l ) lol)\n ls" | ./42sh &> log.txt
  1515. echo -e "foreach x (lol ( l ) lol)\n ls" | tcsh &> tcsh.txt
  1516.  
  1517. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1518.  
  1519. if [ "$DIFF" != "" ]; then
  1520.     echo -e "   11  redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1521.     ((number_of_test_sh2++))
  1522. else {
  1523.     echo -e "    11   redirection (look .sh) test PASSED\n"
  1524.     ((test_passed++))
  1525.     ((number_of_test_sh2++))
  1526. }
  1527. fi
  1528.  
  1529.  
  1530. #Pipe2
  1531. echo -e "foreach x (lol ( l ) lol)\n ls \n end" | ./42sh &> log.txt
  1532. echo -e "foreach x (lol ( l ) lol)\n ls \n end" | tcsh &> tcsh.txt
  1533.  
  1534. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1535.  
  1536. if [ "$DIFF" != "" ]; then
  1537.     echo -e "   12   redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1538.     ((number_of_test_sh2++))
  1539. else {
  1540.     echo -e "    12   redirection (look .sh) test PASSED\n"
  1541.     ((test_passed++))
  1542.     ((number_of_test_sh2++))
  1543. }
  1544. fi
  1545.  
  1546.  
  1547. #Pipe2
  1548. echo "foreach x" | ./42sh &> log.txt
  1549. echo "foreach x" | tcsh &> tcsh.txt
  1550.  
  1551. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1552.  
  1553. if [ "$DIFF" != "" ]; then
  1554.     echo -e "   13   redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1555.     ((number_of_test_sh2++))
  1556. else {
  1557.     echo -e "    13   redirection (look .sh) test PASSED\n"
  1558.     ((test_passed++))
  1559.     ((number_of_test_sh2++))
  1560. }
  1561. fi
  1562.  
  1563.  
  1564. #Pipe2
  1565. echo "foreach x (1)" | ./42sh &> log.txt
  1566. echo "foreach x (1)" | tcsh &> tcsh.txt
  1567.  
  1568. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1569.  
  1570. if [ "$DIFF" != "" ]; then
  1571.     echo -e "  14   redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1572.     ((number_of_test_sh2++))
  1573. else {
  1574.     echo -e "   14   redirection (look .sh) test PASSED\n"
  1575.     ((test_passed++))
  1576.     ((number_of_test_sh2++))
  1577. }
  1578. fi
  1579.  
  1580. #Pipe2
  1581. echo "foreach x dsfdsf dsfsdf" | ./42sh &> log.txt
  1582. echo "foreach x dsfdsf dsfsdf" | tcsh &> tcsh.txt
  1583.  
  1584. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1585.  
  1586. if [ "$DIFF" != "" ]; then
  1587.     echo -e "  15   redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1588.     ((number_of_test_sh2++))
  1589. else {
  1590.     echo -e "   15   redirection (look .sh) test PASSED\n"
  1591.     ((test_passed++))
  1592.     ((number_of_test_sh2++))
  1593. }
  1594. fi
  1595.  
  1596.  
  1597.  
  1598. #Pipe2
  1599. echo -e "set a=ls \n \$a" | ./42sh &> log.txt
  1600. echo -e "set a=ls \n \$a" | tcsh &> tcsh.txt
  1601.  
  1602.  
  1603. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1604.  
  1605. if [ "$DIFF" != "" ]; then
  1606.     echo -e "  17   redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1607.     ((number_of_test_sh2++))
  1608. else {
  1609.     echo -e "   17   redirection (look .sh) test PASSED\n"
  1610.     ((test_passed++))
  1611.     ((number_of_test_sh2++))
  1612. }
  1613. fi
  1614.  
  1615.  
  1616. #Pipe2
  1617. echo "if ( 1 == 1 ) ls" | ./42sh &> log.txt
  1618. echo "if ( 1 == 1 ) ls" | tcsh &> tcsh.txt
  1619.  
  1620.  
  1621. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1622.  
  1623. if [ "$DIFF" != "" ]; then
  1624.     echo -e "  18  redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1625.     ((number_of_test_sh2++))
  1626. else {
  1627.     echo -e "   18   redirection (look .sh) test PASSED\n"
  1628.     ((test_passed++))
  1629.     ((number_of_test_sh2++))
  1630. }
  1631. fi
  1632.  
  1633.  
  1634. #Pipe2
  1635. echo "if (1 == 1) ls" | ./42sh &> log.txt
  1636. echo "if (1 == 1) ls" | tcsh &> tcsh.txt
  1637.  
  1638. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1639.  
  1640. if [ "$DIFF" != "" ]; then
  1641.     echo -e "  17   redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1642.     ((number_of_test_sh2++))
  1643. else {
  1644.     echo -e "   19  redirection (look .sh) test PASSED\n"
  1645.     ((test_passed++))
  1646.     ((number_of_test_sh2++))
  1647. }
  1648. fi
  1649.  
  1650.  
  1651.  
  1652. #Pipe2
  1653. echo -e "if (1) ls" | ./42sh &> log.txt
  1654. echo -e "if (1) ls" | tcsh &> tcsh.txt
  1655.  
  1656. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1657.  
  1658. if [ "$DIFF" != "" ]; then
  1659.     echo -e "  17   redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1660.     ((number_of_test_sh2++))
  1661. else {
  1662.     echo -e "   20   redirection (look .sh) test PASSED\n"
  1663.     ((test_passed++))
  1664.     ((number_of_test_sh2++))
  1665. }
  1666. fi
  1667.  
  1668. #Pipe2
  1669. echo -e "if 1 ls" | ./42sh &> log.txt
  1670. echo -e "if 1 ls" | tcsh &> tcsh.txt
  1671.  
  1672. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1673.  
  1674. if [ "$DIFF" != "" ]; then
  1675.     echo -e "  17   redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1676.     ((number_of_test_sh2++))
  1677. else {
  1678.     echo -e "   21   redirection (look .sh) test PASSED\n"
  1679.     ((test_passed++))
  1680.     ((number_of_test_sh2++))
  1681. }
  1682. fi
  1683.  
  1684. #Pipe2
  1685. echo -e "if (1 == 1 ) ls" | ./42sh &> log.txt
  1686. echo -e "if (1 == 1 ) ls" | tcsh &> tcsh.txt
  1687.  
  1688. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1689.  
  1690. if [ "$DIFF" != "" ]; then
  1691.     echo -e "  17   redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1692.     ((number_of_test_sh2++))
  1693. else {
  1694.     echo -e "   22  redirection (look .sh) test PASSED\n"
  1695.     ((test_passed++))
  1696.     ((number_of_test_sh2++))
  1697. }
  1698. fi
  1699.  
  1700. #Pipe2
  1701. echo -e "if ( 1 == 1) ls" | ./42sh &> log.txt
  1702. echo -e "if ( 1 == 1) ls" | tcsh &> tcsh.txt
  1703.  
  1704. DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
  1705.  
  1706. if [ "$DIFF" != "" ]; then
  1707.     echo -e "  17   redirection (look .sh): Got: $DIFF\nExpected: \"\"\n"
  1708.     ((number_of_test_sh2++))
  1709. else {
  1710.     echo -e "   23   redirection (look .sh) test PASSED\n"
  1711.     ((test_passed++))
  1712.     ((number_of_test_sh2++))
  1713. }
  1714. fi
  1715.  
  1716. echo "####################################"
  1717. echo "SUCCESS TEST --> " $test_passed
  1718. echo "NUMBER OF SH2 TEST --> " $number_of_test_sh2
  1719. test_fail=$(echo "(44+$number_of_test_sh2)-$test_passed" |bc )
  1720. echo "FAIL TEST --> " $test_fail
  1721. echo "####################################"
  1722.  
  1723. rm -rf log.txt
  1724. rm -rf tcsh.txt
  1725. rm -rf tcssh.txt
  1726. rm file1
  1727. rm ok
  1728. rm salut
  1729. rm yo
  1730. rm -rf report
  1731. echo -e "\n###########################END OF TESTS###########################\n"
  1732. rm tests
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement