mkfs: symlink support
[minix.git] / test / testsh1.sh
blob13407d9a078ea63cc5555e20fd5c8e0af43f84df
1 #!/bin/sh
3 # Shell script used to test MINIX.
5 PATH=:/bin:/usr/bin
6 export PATH
8 echo -n "Shell test 1 "
9 rm -rf DIR_SH1
10 mkdir DIR_SH1
11 cd DIR_SH1
13 f=../test1.c
14 if test -r $f; then : ; else echo sh1 cannot read $f; exit 1; fi
16 #Initial setup
17 echo "abcdefghijklmnopqrstuvwxyz" >alpha
18 echo "ABCDEFGHIJKLMNOPQRSTUVWXYZ" >ALPHA
19 echo "0123456789" >num
20 echo "!@#$%^&*()_+=-{}[]:;<>?/.," >special
21 cp /etc/rc rc
22 cp /etc/passwd passwd
23 cat alpha ALPHA num rc passwd special >tmp
24 cat tmp tmp tmp >f1
27 #Test cp
28 mkdir foo
29 cp /etc/rc /etc/passwd foo
30 if cmp -s foo/rc /etc/rc ; then : ; else echo Error on cp test 1; fi
31 if cmp -s foo/passwd /etc/passwd ; then : ; else echo Error on cp test 2; fi
32 rm -rf foo
34 #Test cat
35 cat num num num num num >y
36 wc -c y >x1
37 echo " 55 y" >x2
38 if cmp -s x1 x2; then : ; else echo Error on cat test 1; fi
39 cat <y >z
40 if cmp -s y z; then : ; else echo Error on cat test 2; fi
42 #Test basename
43 if test `basename /usr/ast/foo.c .c` != 'foo'
44 then echo Error on basename test 1
47 if test `basename a/b/c/d` != 'd'; then Error on basename test 2; fi
49 #Test cdiff, sed, and patch
50 cp $f x.c # x.c is a copy $f
51 echo "/a/s//#####/g" >s # create sed script
52 sed -f s <x.c >y.c # y.c is new version of x.c
53 diff -c x.c y.c >y # y is cdiff listing
54 patch x.c y 2>/dev/null # z should be y.c
55 if cmp -s x.c y.c; then : ; else echo Error in cdiff test; fi
56 rm x.c* y.c s y
58 #Test comm, grep -v
59 ls /etc >x # x = list of /etc
60 grep -v "passwd" x >y # y = x except for /etc/passwd
61 comm -3 x y >z # should only be 1 line, /etc/passwd
62 echo "passwd" >w
63 if cmp -s w z; then : else echo Error on comm test 1; fi
65 comm -13 x y >z # should be empty
66 if test -s z; then echo Error on comm test 2; fi
67 rm -rf w x y z
69 #Test compress
70 compress -fc $f >x.c.Z # compress the test file
71 compress -cd x.c.Z >y # uncompress it
72 if cmp -s $f y; then : else echo Error in compress test 1; fi
73 rm -rf x.c.Z y
75 #Test ed
76 cp $f x # copy $f to x
77 cat >y <<END
78 g/a/s//#####/g
79 g/b/s//@@@@@/g
80 g/c/s//!!!!!/g
83 END
84 ed 2>/dev/null x <y >/dev/null
85 cat >y <<END
86 g/#####/s//a/g
87 g/@@@@@/s//b/g
88 g/!!!!!/s//c/g
91 END
92 ed 2>/dev/null x <y >/dev/null
93 if cmp -s x $f; then : ; else echo Error in ed test 1; fi
94 rm x y
96 #Test expr
97 if test `expr 1 + 1` != 2; then echo Error on expr test 1; fi
98 if test `expr 10000 - 1` != 9999; then echo Error on expr test 2; fi
99 if test `expr 100 '*' 50` != 5000; then echo Error on expr test 3; fi
100 if test `expr 120 / 5` != 24; then echo Error on expr test 4; fi
101 if test `expr 143 % 7` != 3; then echo Error on expr test 5; fi
102 a=100
103 a=`expr $a + 1`
104 if test $a != '101'; then echo Error on expr test 6; fi
106 #Test fgrep
107 fgrep "abc" alpha >z
108 if cmp -s alpha z ; then : else echo Error on fgrep test 1; fi
109 fgrep "abc" num >z
110 if test -s z; then echo Error on fgrep test 2; fi
111 cat alpha num >z
112 fgrep "012" z >w
113 if cmp -s w num; then : ; else echo Error fgrep test 3; fi
116 #Test find
117 date >Rabbit
118 echo "Rabbit" >y
119 find . -name Rabbit -print >z
120 if cmp -s y z; then : else echo Error on find test 1; fi
121 find . -name Bunny -print >z
122 if test -s z; then echo Error on find test 2; fi
123 rm Rabbit y z
125 #Test grep
126 grep "a" alpha >x
127 if cmp -s x alpha; then : ; else echo Error on grep test 1; fi
128 grep "a" ALPHA >x
129 if test -s x; then echo Error on grep test 2; fi
130 grep -v "0" alpha >x
131 if cmp -s x alpha; then : ; else echo Error on grep test 3; fi
132 grep -s "a" XXX_nonexistent_file_XXX >x
133 if test -s x; then echo "Error on grep test 4"; fi
134 if grep -s "a" alpha >x; then : else echo Error on grep test 5; fi
135 if grep -s "a" ALPHA >x; then echo Error on grep test 6; fi
137 #Test head
138 head -1 f1 >x
139 if cmp -s x alpha; then : else echo Error on head test 1; fi
140 head -2 f1 >x
141 cat alpha ALPHA >y
142 if cmp -s x y; then : else echo Error on head test 2; fi
144 #Test ls
145 mkdir FOO
146 cp passwd FOO/z
147 cp alpha FOO/x
148 cp ALPHA FOO/y
149 cd FOO
150 ls >w
151 cat >w1 <<END
157 if cmp -s w w1; then : ; else echo Error on ls test 1; fi
158 rm *
159 cd ..
160 rmdir FOO
162 #Test mkdir/rmdir
163 mkdir Foo Bar
164 if test -d Foo; then : ; else echo Error on mkdir test 1; fi
165 if test -d Bar; then : ; else echo Error on mkdir test 2; fi
166 rmdir Foo Bar
167 if test -d Foo; then echo Error on mkdir test 3; fi
168 if test -d Foo; then echo Error on rmdir test 4; fi
170 #Test mv
171 mkdir MVDIR
172 cp $f x
173 mv x y
174 mv y z
175 if cmp -s $f z; then : ; else echo Error on mv test 1; fi
176 cp $f x
177 mv x MVDIR/y
178 if cmp -s $f MVDIR/y; then : ; else echo Error on mv test 2; fi
180 #Test rev
181 rev <f1 | head -1 >ahpla
182 echo "zyxwvutsrqponmlkjihgfedcba" >x
183 if cmp -s x ahpla; then : ; else echo Error on rev test 1; fi
184 rev <$f >x
185 rev <x >y
186 if cmp -s $f x; then echo Error on rev test 2; fi
187 if cmp -s $f y; then : ; else echo error on rev test 3; fi
189 #Test shar
190 cp $f w
191 cp alpha x
192 cp ALPHA y
193 cp num z
194 shar w x y z >x1
195 rm w x y z
196 sh <x1 >/dev/null
197 if cmp -s w $f; then : ; else echo Error on shar test 1; fi
198 if cmp -s x alpha; then : ; else echo Error on shar test 2; fi
199 if cmp -s y ALPHA; then : ; else echo Error on shar test 3; fi
200 if cmp -s z num; then : ; else echo Error on shar test 4; fi
202 #Test sort
203 sort <$f >x
204 wc <$f >x1
205 wc <x >x2
206 if cmp -s x1 x2; then : ; else echo Error on sort test 1; fi
207 cat >x <<END
208 demit 10
209 epitonic 40
210 apoop 20
211 bibelot 3
212 comate 4
214 cat >y <<END
215 apoop 20
216 bibelot 3
217 comate 4
218 demit 10
219 epitonic 40
221 cat >z <<END
222 epitonic 40
223 demit 10
224 comate 4
225 bibelot 3
226 apoop 20
228 sort <x >x1
229 if cmp -s y x1; then : ; else echo Error on sort test 2; fi
230 sort -r <x1 >x2
231 if cmp -s x2 z; then : ; else echo Error on sort test 3; fi
232 sort +1 -n <x |head -1 >y
233 echo "bibelot 3" >z
234 if cmp -s y z; then : ; else echo Error on sort test 4; fi
236 #Test tail
237 tail -1 f1 >x
238 if cmp -s x special; then : ; else echo Error on tail test 1; fi
240 #Test tsort
241 cat >x <<END
256 cat >answer <<END
267 tsort <x >y
268 if cmp -s y answer; then : ; else echo Error on tsort test 1; fi
270 #Test uue/uud
271 cp $f x
272 uue x
273 if test -s x.uue; then : ; else echo Error on uue/uud test 1; fi
274 rm x
275 uud x.uue
276 if cmp -s x $f; then : ; else echo Error on uue/uud test 2; fi
278 compress -fc x >x.Z 2>/dev/null
279 uue x.Z
280 rm x x.Z
281 uud x.uue
282 compress -cd x.Z >x
283 if cmp -s x $f; then : ; else echo Error on uue/uud test 3; fi
285 cd ..
286 rm -rf DIR_SH1
288 echo ok