- retrieve binary packages and sources from webserver to make a release, incremental...
[minix.git] / test / testsh1.sh
blob6412290dc2c7b6b4fa51983eedd9fc629a889b1c
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 ar
43 cat passwd >p
44 cp passwd q
45 if cmp -s p q; then : ; else echo Error on ar test 1; fi
46 date >r
47 ar r x.a p q r 2>/dev/null
48 ar r x.a /usr/bin/cp
49 ar r x.a /usr/bin/cat
50 rm p q
51 mv r R
52 ar x x.a
53 if cmp -s p /etc/passwd; then : ; else Error on ar test 2; fi
54 if cmp -s q /etc/passwd; then : ; else Error on ar test 3; fi
55 if cmp -s r R; then : ; else Error on ar test 4; fi
56 if cmp -s cp /usr/bin/cp; then : ; else Error on ar test 5; fi
57 if cmp -s cat /usr/bin/cat; then : ; else Error on ar test 6; fi
58 rm cp cat p q r
59 ar d x.a r >/dev/null
60 ar x x.a
61 if test -r r; then echo Error on ar test 7; fi
62 rm -rf p q r R
64 #Test basename
65 if test `basename /usr/ast/foo.c .c` != 'foo'
66 then echo Error on basename test 1
69 if test `basename a/b/c/d` != 'd'; then Error on basename test 2; fi
71 #Test cdiff, sed, and patch
72 cp $f x.c # x.c is a copy $f
73 echo "/a/s//#####/g" >s # create sed script
74 sed -f s <x.c >y.c # y.c is new version of x.c
75 cdiff x.c y.c >y # y is cdiff listing
76 patch x.c y 2>/dev/null # z should be y.c
77 if cmp -s x.c y.c; then : ; else echo Error in cdiff test; fi
78 rm x.c* y.c s y
80 #Test comm, grep -v
81 ls /etc >x # x = list of /etc
82 grep -v "passwd" x >y # y = x except for /etc/passwd
83 comm -3 x y >z # should only be 1 line, /etc/passwd
84 echo "passwd" >w
85 if cmp -s w z; then : else echo Error on comm test 1; fi
87 comm -13 x y >z # should be empty
88 if test -s z; then echo Error on comm test 2; fi
89 rm -rf w x y z
91 #Test compress
92 compress -fc $f >x.c.Z # compress the test file
93 compress -cd x.c.Z >y # uncompress it
94 if cmp -s $f y; then : else echo Error in compress test 1; fi
95 rm -rf x.c.Z y
97 #Test ed
98 cp $f x # copy $f to x
99 cat >y <<END
100 g/a/s//#####/g
101 g/b/s//@@@@@/g
102 g/c/s//!!!!!/g
106 ed x <y >/dev/null
107 cat >y <<END
108 g/#####/s//a/g
109 g/@@@@@/s//b/g
110 g/!!!!!/s//c/g
114 ed x <y >/dev/null
115 if cmp -s x $f; then : ; else echo Error in ed test 1; fi
116 rm x y
118 #Test expr
119 if test `expr 1 + 1` != 2; then echo Error on expr test 1; fi
120 if test `expr 10000 - 1` != 9999; then echo Error on expr test 2; fi
121 if test `expr 100 '*' 50` != 5000; then echo Error on expr test 3; fi
122 if test `expr 120 / 5` != 24; then echo Error on expr test 4; fi
123 if test `expr 143 % 7` != 3; then echo Error on expr test 5; fi
124 a=100
125 a=`expr $a + 1`
126 if test $a != '101'; then echo Error on expr test 6; fi
128 #Test fgrep
129 fgrep "abc" alpha >z
130 if cmp -s alpha z ; then : else echo Error on fgrep test 1; fi
131 fgrep "abc" num >z
132 if test -s z; then echo Error on fgrep test 2; fi
133 cat alpha num >z
134 fgrep "012" z >w
135 if cmp -s w num; then : ; else echo Error fgrep test 3; fi
138 #Test find
139 date >Rabbit
140 echo "Rabbit" >y
141 find . -name Rabbit -print >z
142 if cmp -s y z; then : else echo Error on find test 1; fi
143 find . -name Bunny -print >z
144 if test -s z; then echo Error on find test 2; fi
145 rm Rabbit y z
147 #Test grep
148 grep "a" alpha >x
149 if cmp -s x alpha; then : ; else echo Error on grep test 1; fi
150 grep "a" ALPHA >x
151 if test -s x; then echo Error on grep test 2; fi
152 grep -v "0" alpha >x
153 if cmp -s x alpha; then : ; else echo Error on grep test 3; fi
154 grep -s "a" alpha >x
155 if test -s x; then echo Error on grep test 4; fi
156 if grep -s "a" alpha >x; then : else echo Error on grep test 5; fi
157 if grep -s "a" ALPHA >x; then echo Error on grep test 6; fi
159 #Test head
160 head -1 f1 >x
161 if cmp -s x alpha; then : else echo Error on head test 1; fi
162 head -2 f1 >x
163 cat alpha ALPHA >y
164 if cmp -s x y; then : else echo Error on head test 2; fi
166 #Test ls
167 mkdir FOO
168 cp passwd FOO/z
169 cp alpha FOO/x
170 cp ALPHA FOO/y
171 cd FOO
172 ls >w
173 cat >w1 <<END
179 if cmp -s w w1; then : ; else echo Error on ls test 1; fi
180 rm *
181 cd ..
182 rmdir FOO
184 #Test mkdir/rmdir
185 mkdir Foo Bar
186 if test -d Foo; then : ; else echo Error on mkdir test 1; fi
187 if test -d Bar; then : ; else echo Error on mkdir test 2; fi
188 rmdir Foo Bar
189 if test -d Foo; then echo Error on mkdir test 3; fi
190 if test -d Foo; then echo Error on rmdir test 4; fi
192 #Test mv
193 mkdir MVDIR
194 cp $f x
195 mv x y
196 mv y z
197 if cmp -s $f z; then : ; else echo Error on mv test 1; fi
198 cp $f x
199 mv x MVDIR/y
200 if cmp -s $f MVDIR/y; then : ; else echo Error on mv test 2; fi
202 #Test rev
203 rev <f1 | head -1 >ahpla
204 echo "zyxwvutsrqponmlkjihgfedcba" >x
205 if cmp -s x ahpla; then : ; else echo Error on rev test 1; fi
206 rev <$f >x
207 rev <x >y
208 if cmp -s $f x; then echo Error on rev test 2; fi
209 if cmp -s $f y; then : ; else echo error on rev test 3; fi
211 #Test shar
212 cp $f w
213 cp alpha x
214 cp ALPHA y
215 cp num z
216 shar w x y z >x1
217 rm w x y z
218 sh <x1 >/dev/null
219 if cmp -s w $f; then : ; else echo Error on shar test 1; fi
220 if cmp -s x alpha; then : ; else echo Error on shar test 2; fi
221 if cmp -s y ALPHA; then : ; else echo Error on shar test 3; fi
222 if cmp -s z num; then : ; else echo Error on shar test 4; fi
224 #Test sort
225 sort <$f >x
226 wc <$f >x1
227 wc <x >x2
228 if cmp -s x1 x2; then : ; else echo Error on sort test 1; fi
229 cat >x <<END
230 demit 10
231 epitonic 40
232 apoop 20
233 bibelot 3
234 comate 4
236 cat >y <<END
237 apoop 20
238 bibelot 3
239 comate 4
240 demit 10
241 epitonic 40
243 cat >z <<END
244 epitonic 40
245 demit 10
246 comate 4
247 bibelot 3
248 apoop 20
250 sort <x >x1
251 if cmp -s y x1; then : ; else echo Error on sort test 2; fi
252 sort -r <x1 >x2
253 if cmp -s x2 z; then : ; else echo Error on sort test 3; fi
254 sort +1 -n <x |head -1 >y
255 echo "bibelot 3" >z
256 if cmp -s y z; then : ; else echo Error on sort test 4; fi
258 #Test tail
259 tail -1 f1 >x
260 if cmp -s x special; then : ; else echo Error on tail test 1; fi
262 #Test tsort
263 cat >x <<END
278 cat >answer <<END
289 tsort <x >y
290 if cmp -s y answer; then : ; else echo Error on tsort test 1; fi
292 #Test uue/uud
293 cp $f x
294 uue x
295 if test -s x.uue; then : ; else echo Error on uue/uud test 1; fi
296 rm x
297 uud x.uue
298 if cmp -s x $f; then : ; else echo Error on uue/uud test 2; fi
300 compress -fc x >x.Z 2>/dev/null
301 uue x.Z
302 rm x x.Z
303 uud x.uue
304 compress -cd x.Z >x
305 if cmp -s x $f; then : ; else echo Error on uue/uud test 3; fi
307 cd ..
308 rm -rf DIR_SH1
310 echo ok