make vfs & filesystems use failable copying
[minix3.git] / test / testsh1.sh
blobc094d843459dac0011986977ba481c5f7e1202dd
1 #!/bin/sh
3 # Shell script used to test MINIX.
5 # Helper function
6 bomb() {
7 echo $*
8 cd ..
9 rm -rf $TESTDIR
10 exit 1
14 PATH=:/bin:/usr/bin
15 export PATH
17 TESTDIR=DIR_SH1
18 export TESTDIR
20 OLDPWD=`pwd`
21 export OLDPWD
23 echo -n "Shell test 1 "
24 rm -rf $TESTDIR
25 mkdir $TESTDIR
26 cd $TESTDIR
28 f=$OLDPWD/test1.c
29 if test -r $f; then : ; else echo sh1 cannot read $f; exit 1; fi
31 #Initial setup
32 echo "abcdefghijklmnopqrstuvwxyz" >alpha
33 echo "ABCDEFGHIJKLMNOPQRSTUVWXYZ" >ALPHA
34 echo "0123456789" >num
35 echo "!@#$%^&*()_+=-{}[]:;<>?/.," >special
36 cp /etc/rc rc
37 cp /etc/passwd passwd
38 cat alpha ALPHA num rc passwd special >tmp
39 cat tmp tmp tmp >f1
42 #Test cp
43 mkdir foo
44 cp /etc/rc /etc/passwd foo
45 if cmp -s foo/rc /etc/rc ; then : ; else bomb "Error on cp test 1"; fi
46 if cmp -s foo/passwd /etc/passwd ; then : ; else bomb "Error on cp test 2"; fi
47 rm -rf foo
49 #Test cat
50 cat num num num num num >y
51 wc -c y >x1
52 echo " 55 y" >x2
53 if cmp -s x1 x2; then : ; else bomb "Error on cat test 1"; fi
54 cat <y >z
55 if cmp -s y z; then : ; else bomb "Error on cat test 2"; fi
57 #Test basename
58 if test `basename /usr/ast/foo.c .c` != 'foo'
59 then bomb "Error on basename test 1"
62 if test `basename a/b/c/d` != 'd'; then bomb "Error on basename test 2"; fi
64 #Test cdiff, sed, and patch
65 cp $f x.c # x.c is a copy $f
66 echo "/a/s//#####/g" >s # create sed script
67 sed -f s <x.c >y.c # y.c is new version of x.c
68 diff -c x.c y.c >y # y is cdiff listing
69 patch x.c y 2>/dev/null # z should be y.c
70 if cmp -s x.c y.c; then : ; else bomb "Error in cdiff test"; fi
71 rm x.c* y.c s y
73 #Test comm, grep -v
74 ls /etc >x # x = list of /etc
75 grep -v "passwd" x >y # y = x except for /etc/passwd
76 comm -3 x y >z # should only be 1 line, /etc/passwd
77 echo "passwd" >w
78 if cmp -s w z; then : else bomb "Error on comm test 1"; fi
80 comm -13 x y >z # should be empty
81 if test -s z; then bomb "Error on comm test 2"; fi
82 rm -rf w x y z
84 #Test compress
85 compress -fc $f >x.c.Z # compress the test file
86 compress -cd x.c.Z >y # uncompress it
87 if cmp -s $f y; then : else bomb "Error in compress test 1"; fi
88 rm -rf x.c.Z y
90 #Test ed
91 cp $f x # copy $f to x
92 cat >y <<END
93 g/a/s//#####/g
94 g/b/s//@@@@@/g
95 g/c/s//!!!!!/g
98 END
99 ed 2>/dev/null x <y >/dev/null
100 cat >y <<END
101 g/#####/s//a/g
102 g/@@@@@/s//b/g
103 g/!!!!!/s//c/g
107 ed 2>/dev/null x <y >/dev/null
108 if cmp -s x $f; then : ; else bomb "Error in ed test 1"; fi
109 rm x y
111 #Test expr
112 if test `expr 1 + 1` != 2; then bomb "Error on expr test 1"; fi
113 if test `expr 10000 - 1` != 9999; then bomb "Error on expr test 2"; fi
114 if test `expr 100 '*' 50` != 5000; then bomb "Error on expr test 3"; fi
115 if test `expr 120 / 5` != 24; then bomb "Error on expr test 4"; fi
116 if test `expr 143 % 7` != 3; then bomb "Error on expr test 5"; fi
117 a=100
118 a=`expr $a + 1`
119 if test $a != '101'; then bomb "Error on expr test 6"; fi
121 #Test fgrep
122 fgrep "abc" alpha >z
123 if cmp -s alpha z ; then : else bomb "Error on fgrep test 1"; fi
124 fgrep "abc" num >z
125 if test -s z; then bomb "Error on fgrep test 2"; fi
126 cat alpha num >z
127 fgrep "012" z >w
128 if cmp -s w num; then : ; else bomb "Error fgrep test 3"; fi
131 #Test find
132 date >Rabbit
133 echo "Rabbit" >y
134 find . -name Rabbit -print >z
135 if cmp -s y z; then : else bomb "Error on find test 1"; fi
136 find . -name Bunny -print >z
137 if test -s z; then bomb "Error on find test 2"; fi
138 rm Rabbit y z
140 #Test grep
141 grep "a" alpha >x
142 if cmp -s x alpha; then : ; else bomb "Error on grep test 1"; fi
143 grep "a" ALPHA >x
144 if test -s x; then bomb "Error on grep test 2"; fi
145 grep -v "0" alpha >x
146 if cmp -s x alpha; then : ; else bomb "Error on grep test 3"; fi
147 grep -s "a" XXX_nonexistent_file_XXX >x
148 if test -s x; then echo "Error on grep test 4"; fi
149 if grep -s "a" alpha >x; then : else bomb "Error on grep test 5"; fi
150 if grep -s "a" ALPHA >x; then bomb "Error on grep test 6"; fi
152 #Test head
153 head -1 f1 >x
154 if cmp -s x alpha; then : else bomb "Error on head test 1"; fi
155 head -2 f1 >x
156 cat alpha ALPHA >y
157 if cmp -s x y; then : else bomb "Error on head test 2"; fi
159 #Test ls
160 mkdir FOO
161 cp passwd FOO/z
162 cp alpha FOO/x
163 cp ALPHA FOO/y
164 cd FOO
165 ls >w
166 cat >w1 <<END
172 if cmp -s w w1; then : ; else bomb "Error on ls test 1"; fi
173 rm *
174 cd ..
175 rmdir FOO
177 #Test mkdir/rmdir
178 mkdir Foo Bar
179 if test -d Foo; then : ; else bomb "Error on mkdir test 1"; fi
180 if test -d Bar; then : ; else bomb "Error on mkdir test 2"; fi
181 rmdir Foo Bar
182 if test -d Foo; then bomb "Error on mkdir test 3"; fi
183 if test -d Foo; then bomb "Error on rmdir test 4"; fi
185 #Test mv
186 mkdir MVDIR
187 cp $f x
188 mv x y
189 mv y z
190 if cmp -s $f z; then : ; else bomb "Error on mv test 1"; fi
191 cp $f x
192 mv x MVDIR/y
193 if cmp -s $f MVDIR/y; then : ; else bomb "Error on mv test 2"; fi
195 #Test rev
196 rev <f1 | head -1 >ahpla
197 echo "zyxwvutsrqponmlkjihgfedcba" >x
198 if cmp -s x ahpla; then : ; else bomb "Error on rev test 1"; fi
199 rev <$f >x
200 rev <x >y
201 if cmp -s $f x; then bomb "Error on rev test 2"; fi
202 if cmp -s $f y; then : ; else bomb "Error on rev test 3"; fi
204 #Test shar
205 cp $f w
206 cp alpha x
207 cp ALPHA y
208 cp num z
209 shar w x y z >x1
210 rm w x y z
211 sh <x1 >/dev/null
212 if cmp -s w $f; then : ; else bomb "Error on shar test 1"; fi
213 if cmp -s x alpha; then : ; else bomb "Error on shar test 2"; fi
214 if cmp -s y ALPHA; then : ; else bomb "Error on shar test 3"; fi
215 if cmp -s z num; then : ; else bomb "Error on shar test 4"; fi
217 #Test sort
218 sort <$f >x
219 wc <$f >x1
220 wc <x >x2
221 if cmp -s x1 x2; then : ; else bomb "Error on sort test 1"; fi
222 cat >x <<END
223 demit 10
224 epitonic 40
225 apoop 20
226 bibelot 3
227 comate 4
229 cat >y <<END
230 apoop 20
231 bibelot 3
232 comate 4
233 demit 10
234 epitonic 40
236 cat >z <<END
237 epitonic 40
238 demit 10
239 comate 4
240 bibelot 3
241 apoop 20
243 sort <x >x1
244 if cmp -s y x1; then : ; else bomb "Error on sort test 2"; fi
245 sort -r <x1 >x2
246 if cmp -s x2 z; then : ; else bomb "Error on sort test 3"; fi
247 sort -k 2n <x |head -1 >y
248 echo "bibelot 3" >z
249 if cmp -s y z; then : ; else bomb "Error on sort test 4"; fi
251 #Test tail
252 tail -1 f1 >x
253 if cmp -s x special; then : ; else bomb "Error on tail test 1"; fi
255 #Test tsort
256 cat >x <<END
271 cat >answer <<END
282 tsort <x >y
283 if cmp -s y answer; then : ; else bomb "Error on tsort test 1"; fi
285 #Test uue/uud
286 cp $f x
287 uue x
288 if test -s x.uue; then : ; else bomb "Error on uue/uud test 1"; fi
289 rm x
290 uud x.uue
291 if cmp -s x $f; then : ; else bomb "Error on uue/uud test 2"; fi
293 compress -fc x >x.Z 2>/dev/null
294 uue x.Z
295 rm x x.Z
296 uud x.uue
297 compress -cd x.Z >x
298 if cmp -s x $f; then : ; else bomb "Error on uue/uud test 3"; fi
300 cd ..
301 rm -rf $TESTDIR
303 echo ok