#!/bin/sh # Shell script used to test MINIX. setglobal PATH = ':/bin:/usr/bin' export PATH echo -n "Shell test 1 " rm -rf DIR_SH1 mkdir DIR_SH1 cd DIR_SH1 setglobal f = '../test1.c' if test -r $f { : ; } else { echo sh1 cannot read $f; exit 1; } #Initial setup echo "abcdefghijklmnopqrstuvwxyz" >alpha echo "ABCDEFGHIJKLMNOPQRSTUVWXYZ" >ALPHA echo "0123456789" >num echo "!@#$%^&*()_+=-{}[]:;<>?/.," >special cp /etc/rc rc cp /etc/passwd passwd cat alpha ALPHA num rc passwd special >tmp cat tmp tmp tmp >f1 #Test cp mkdir foo cp /etc/rc /etc/passwd foo if cmp -s foo/rc /etc/rc { : ; } else { echo Error on cp test 1; } if cmp -s foo/passwd /etc/passwd { : ; } else { echo Error on cp test 2; } rm -rf foo #Test cat cat num num num num num >y wc -c y >x1 echo " 55 y" >x2 if cmp -s x1 x2 { : ; } else { echo Error on cat test 1; } cat z if cmp -s y z { : ; } else { echo Error on cat test 2; } #Test ar cat passwd >p cp passwd q if cmp -s p q { : ; } else { echo Error on ar test 1; } date >r ar r x.a p q r !2 >/dev/null ar r x.a /usr/bin/cp ar r x.a /usr/bin/cat rm p q mv r R ar x x.a if cmp -s p /etc/passwd { : ; } else { Error on ar test 2; } if cmp -s q /etc/passwd { : ; } else { Error on ar test 3; } if cmp -s r R { : ; } else { Error on ar test 4; } if cmp -s cp /usr/bin/cp { : ; } else { Error on ar test 5; } if cmp -s cat /usr/bin/cat { : ; } else { Error on ar test 6; } rm cp cat p q r ar d x.a r >/dev/null ar x x.a if test -r r { echo Error on ar test 7; } rm -rf p q r R #Test basename if test $[basename /usr/ast/foo.c .c] != 'foo' { echo Error on basename test 1 } if test $[basename a/b/c/d] != 'd' { Error on basename test 2; } #Test cdiff, sed, and patch cp $f x.c # x.c is a copy $f echo "/a/s//#####/g" >s # create sed script sed -f s y.c # y.c is new version of x.c cdiff x.c y.c >y # y is cdiff listing patch x.c y !2 >/dev/null # z should be y.c if cmp -s x.c y.c { : ; } else { echo Error in cdiff test; } rm x.c* y.c s y #Test comm, grep -v ls /etc >x # x = list of /etc grep -v "passwd" x >y # y = x except for /etc/passwd comm -3 x y >z # should only be 1 line, /etc/passwd echo "passwd" >w if cmp -s w z { : else echo Error on comm test 1; } comm -13 x y >z # should be empty if test -s z { echo Error on comm test 2; } rm -rf w x y z #Test compress compress -fc $f >x.c.Z # compress the test file compress -cd x.c.Z >y # uncompress it if cmp -s $f y { : else echo Error in compress test 1; } rm -rf x.c.Z y #Test ed cp $f x # copy $f to x cat >y << """ g/a/s//#####/g g/b/s//@@@@@/g g/c/s//!!!!!/g w q """ ed x /dev/null cat >y << """ g/#####/s//a/g g/@@@@@/s//b/g g/!!!!!/s//c/g w q """ ed x /dev/null if cmp -s x $f { : ; } else { echo Error in ed test 1; } rm x y #Test expr if test $[expr 1 + 1] != 2 { echo Error on expr test 1; } if test $[expr 10000 - 1] != 9999 { echo Error on expr test 2; } if test $[expr 100 '*' 50] != 5000 { echo Error on expr test 3; } if test $[expr 120 / 5] != 24 { echo Error on expr test 4; } if test $[expr 143 % 7] != 3 { echo Error on expr test 5; } setglobal a = '100' setglobal a = $[expr $a + 1] if test $a != '101' { echo Error on expr test 6; } #Test fgrep fgrep "abc" alpha >z if cmp -s alpha z { : else echo Error on fgrep test 1; } fgrep "abc" num >z if test -s z { echo Error on fgrep test 2; } cat alpha num >z fgrep "012" z >w if cmp -s w num { : ; } else { echo Error fgrep test 3; } #Test find date >Rabbit echo "Rabbit" >y find . -name Rabbit -print >z if cmp -s y z { : else echo Error on find test 1; } find . -name Bunny -print >z if test -s z { echo Error on find test 2; } rm Rabbit y z #Test grep grep "a" alpha >x if cmp -s x alpha { : ; } else { echo Error on grep test 1; } grep "a" ALPHA >x if test -s x { echo Error on grep test 2; } grep -v "0" alpha >x if cmp -s x alpha { : ; } else { echo Error on grep test 3; } grep -s "a" alpha >x if test -s x { echo Error on grep test 4; } if grep -s "a" alpha >x { : else echo Error on grep test 5; } if grep -s "a" ALPHA >x { echo Error on grep test 6; } #Test head head -1 f1 >x if cmp -s x alpha { : else echo Error on head test 1; } head -2 f1 >x cat alpha ALPHA >y if cmp -s x y { : else echo Error on head test 2; } #Test ls mkdir FOO cp passwd FOO/z cp alpha FOO/x cp ALPHA FOO/y cd FOO ls >w cat >w1 << """ w x y z """ if cmp -s w w1 { : ; } else { echo Error on ls test 1; } rm * cd .. rmdir FOO #Test mkdir/rmdir mkdir Foo Bar if test -d Foo { : ; } else { echo Error on mkdir test 1; } if test -d Bar { : ; } else { echo Error on mkdir test 2; } rmdir Foo Bar if test -d Foo { echo Error on mkdir test 3; } if test -d Foo { echo Error on rmdir test 4; } #Test mv mkdir MVDIR cp $f x mv x y mv y z if cmp -s $f z { : ; } else { echo Error on mv test 1; } cp $f x mv x MVDIR/y if cmp -s $f MVDIR/y { : ; } else { echo Error on mv test 2; } #Test rev rev ahpla echo "zyxwvutsrqponmlkjihgfedcba" >x if cmp -s x ahpla { : ; } else { echo Error on rev test 1; } rev <$f >x rev y if cmp -s $f x { echo Error on rev test 2; } if cmp -s $f y { : ; } else { echo error on rev test 3; } #Test shar cp $f w cp alpha x cp ALPHA y cp num z shar w x y z >x1 rm w x y z sh /dev/null if cmp -s w $f { : ; } else { echo Error on shar test 1; } if cmp -s x alpha { : ; } else { echo Error on shar test 2; } if cmp -s y ALPHA { : ; } else { echo Error on shar test 3; } if cmp -s z num { : ; } else { echo Error on shar test 4; } #Test sort sort <$f >x wc <$f >x1 wc x2 if cmp -s x1 x2 { : ; } else { echo Error on sort test 1; } cat >x << """ demit 10 epitonic 40 apoop 20 bibelot 3 comate 4 """ cat >y << """ apoop 20 bibelot 3 comate 4 demit 10 epitonic 40 """ cat >z << """ epitonic 40 demit 10 comate 4 bibelot 3 apoop 20 """ sort x1 if cmp -s y x1 { : ; } else { echo Error on sort test 2; } sort -r x2 if cmp -s x2 z { : ; } else { echo Error on sort test 3; } sort +1 -n y echo "bibelot 3" >z if cmp -s y z { : ; } else { echo Error on sort test 4; } #Test tail tail -1 f1 >x if cmp -s x special { : ; } else { echo Error on tail test 1; } #Test tsort cat >x << """ a d b e c f a c p z k p a k a b b c c d d e e f f k """ cat >answer << """ a b c d e f k p z """ tsort y if cmp -s y answer { : ; } else { echo Error on tsort test 1; } #Test uue/uud cp $f x uue x if test -s x.uue { : ; } else { echo Error on uue/uud test 1; } rm x uud x.uue if cmp -s x $f { : ; } else { echo Error on uue/uud test 2; } compress -fc x >x.Z !2 >/dev/null uue x.Z rm x x.Z uud x.uue compress -cd x.Z >x if cmp -s x $f { : ; } else { echo Error on uue/uud test 3; } cd .. rm -rf DIR_SH1 echo ok