source: trunk/minix/test/testsh1.sh@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

  • Property svn:executable set to *
File size: 6.6 KB
Line 
1#!/bin/sh
2
3# Shell script used to test MINIX.
4
5PATH=:/bin:/usr/bin
6export PATH
7
8echo -n "Shell test 1 "
9rm -rf DIR_SH1
10mkdir DIR_SH1
11cd DIR_SH1
12
13f=../test1.c
14if test -r $f; then : ; else echo sh1 cannot read $f; exit 1; fi
15
16#Initial setup
17echo "abcdefghijklmnopqrstuvwxyz" >alpha
18echo "ABCDEFGHIJKLMNOPQRSTUVWXYZ" >ALPHA
19echo "0123456789" >num
20echo "!@#$%^&*()_+=-{}[]:;<>?/.," >special
21cp /etc/rc rc
22cp /etc/passwd passwd
23cat alpha ALPHA num rc passwd special >tmp
24cat tmp tmp tmp >f1
25
26
27#Test cp
28mkdir foo
29cp /etc/rc /etc/passwd foo
30if cmp -s foo/rc /etc/rc ; then : ; else echo Error on cp test 1; fi
31if cmp -s foo/passwd /etc/passwd ; then : ; else echo Error on cp test 2; fi
32rm -rf foo
33
34#Test cat
35cat num num num num num >y
36wc -c y >x1
37echo " 55 y" >x2
38if cmp -s x1 x2; then : ; else echo Error on cat test 1; fi
39cat <y >z
40if cmp -s y z; then : ; else echo Error on cat test 2; fi
41
42#Test ar
43cat passwd >p
44cp passwd q
45if cmp -s p q; then : ; else echo Error on ar test 1; fi
46date >r
47ar r x.a p q r 2>/dev/null
48ar r x.a /usr/bin/cp
49ar r x.a /usr/bin/cat
50rm p q
51mv r R
52ar x x.a
53if cmp -s p /etc/passwd; then : ; else Error on ar test 2; fi
54if cmp -s q /etc/passwd; then : ; else Error on ar test 3; fi
55if cmp -s r R; then : ; else Error on ar test 4; fi
56if cmp -s cp /usr/bin/cp; then : ; else Error on ar test 5; fi
57if cmp -s cat /usr/bin/cat; then : ; else Error on ar test 6; fi
58rm cp cat p q r
59ar d x.a r >/dev/null
60ar x x.a
61if test -r r; then echo Error on ar test 7; fi
62rm -rf p q r R
63
64#Test basename
65if test `basename /usr/ast/foo.c .c` != 'foo'
66 then echo Error on basename test 1
67fi
68
69if test `basename a/b/c/d` != 'd'; then Error on basename test 2; fi
70
71#Test cdiff, sed, and patch
72cp $f x.c # x.c is a copy $f
73echo "/a/s//#####/g" >s # create sed script
74sed -f s <x.c >y.c # y.c is new version of x.c
75cdiff x.c y.c >y # y is cdiff listing
76patch x.c y 2>/dev/null # z should be y.c
77if cmp -s x.c y.c; then : ; else echo Error in cdiff test; fi
78rm x.c* y.c s y
79
80#Test comm, grep -v
81ls /etc >x # x = list of /etc
82grep -v "passwd" x >y # y = x except for /etc/passwd
83comm -3 x y >z # should only be 1 line, /etc/passwd
84echo "passwd" >w
85if cmp -s w z; then : else echo Error on comm test 1; fi
86
87comm -13 x y >z # should be empty
88if test -s z; then echo Error on comm test 2; fi
89rm -rf w x y z
90
91#Test compress
92compress -fc $f >x.c.Z # compress the test file
93compress -cd x.c.Z >y # uncompress it
94if cmp -s $f y; then : else echo Error in compress test 1; fi
95rm -rf x.c.Z y
96
97#Test ed
98cp $f x # copy $f to x
99cat >y <<END
100g/a/s//#####/g
101g/b/s//@@@@@/g
102g/c/s//!!!!!/g
103w
104q
105END
106ed x <y >/dev/null
107cat >y <<END
108g/#####/s//a/g
109g/@@@@@/s//b/g
110g/!!!!!/s//c/g
111w
112q
113END
114ed x <y >/dev/null
115if cmp -s x $f; then : ; else echo Error in ed test 1; fi
116rm x y
117
118#Test expr
119if test `expr 1 + 1` != 2; then echo Error on expr test 1; fi
120if test `expr 10000 - 1` != 9999; then echo Error on expr test 2; fi
121if test `expr 100 '*' 50` != 5000; then echo Error on expr test 3; fi
122if test `expr 120 / 5` != 24; then echo Error on expr test 4; fi
123if test `expr 143 % 7` != 3; then echo Error on expr test 5; fi
124a=100
125a=`expr $a + 1`
126if test $a != '101'; then echo Error on expr test 6; fi
127
128#Test fgrep
129fgrep "abc" alpha >z
130if cmp -s alpha z ; then : else echo Error on fgrep test 1; fi
131fgrep "abc" num >z
132if test -s z; then echo Error on fgrep test 2; fi
133cat alpha num >z
134fgrep "012" z >w
135if cmp -s w num; then : ; else echo Error fgrep test 3; fi
136
137
138#Test find
139date >Rabbit
140echo "Rabbit" >y
141find . -name Rabbit -print >z
142if cmp -s y z; then : else echo Error on find test 1; fi
143find . -name Bunny -print >z
144if test -s z; then echo Error on find test 2; fi
145rm Rabbit y z
146
147#Test grep
148grep "a" alpha >x
149if cmp -s x alpha; then : ; else echo Error on grep test 1; fi
150grep "a" ALPHA >x
151if test -s x; then echo Error on grep test 2; fi
152grep -v "0" alpha >x
153if cmp -s x alpha; then : ; else echo Error on grep test 3; fi
154grep -s "a" alpha >x
155if test -s x; then echo Error on grep test 4; fi
156if grep -s "a" alpha >x; then : else echo Error on grep test 5; fi
157if grep -s "a" ALPHA >x; then echo Error on grep test 6; fi
158
159#Test head
160head -1 f1 >x
161if cmp -s x alpha; then : else echo Error on head test 1; fi
162head -2 f1 >x
163cat alpha ALPHA >y
164if cmp -s x y; then : else echo Error on head test 2; fi
165
166#Test ls
167mkdir FOO
168cp passwd FOO/z
169cp alpha FOO/x
170cp ALPHA FOO/y
171cd FOO
172ls >w
173cat >w1 <<END
174w
175x
176y
177z
178END
179if cmp -s w w1; then : ; else echo Error on ls test 1; fi
180rm *
181cd ..
182rmdir FOO
183
184#Test mkdir/rmdir
185mkdir Foo Bar
186if test -d Foo; then : ; else echo Error on mkdir test 1; fi
187if test -d Bar; then : ; else echo Error on mkdir test 2; fi
188rmdir Foo Bar
189if test -d Foo; then echo Error on mkdir test 3; fi
190if test -d Foo; then echo Error on rmdir test 4; fi
191
192#Test mv
193mkdir MVDIR
194cp $f x
195mv x y
196mv y z
197if cmp -s $f z; then : ; else echo Error on mv test 1; fi
198cp $f x
199mv x MVDIR/y
200if cmp -s $f MVDIR/y; then : ; else echo Error on mv test 2; fi
201
202#Test rev
203rev <f1 | head -1 >ahpla
204echo "zyxwvutsrqponmlkjihgfedcba" >x
205if cmp -s x ahpla; then : ; else echo Error on rev test 1; fi
206rev <$f >x
207rev <x >y
208if cmp -s $f x; then echo Error on rev test 2; fi
209if cmp -s $f y; then : ; else echo error on rev test 3; fi
210
211#Test shar
212cp $f w
213cp alpha x
214cp ALPHA y
215cp num z
216shar w x y z >x1
217rm w x y z
218sh <x1 >/dev/null
219if cmp -s w $f; then : ; else echo Error on shar test 1; fi
220if cmp -s x alpha; then : ; else echo Error on shar test 2; fi
221if cmp -s y ALPHA; then : ; else echo Error on shar test 3; fi
222if cmp -s z num; then : ; else echo Error on shar test 4; fi
223
224#Test sort
225sort <$f >x
226wc <$f >x1
227wc <x >x2
228if cmp -s x1 x2; then : ; else echo Error on sort test 1; fi
229cat >x <<END
230demit 10
231epitonic 40
232apoop 20
233bibelot 3
234comate 4
235END
236cat >y <<END
237apoop 20
238bibelot 3
239comate 4
240demit 10
241epitonic 40
242END
243cat >z <<END
244epitonic 40
245demit 10
246comate 4
247bibelot 3
248apoop 20
249END
250sort <x >x1
251if cmp -s y x1; then : ; else echo Error on sort test 2; fi
252sort -r <x1 >x2
253if cmp -s x2 z; then : ; else echo Error on sort test 3; fi
254sort +1 -n <x |head -1 >y
255echo "bibelot 3" >z
256if cmp -s y z; then : ; else echo Error on sort test 4; fi
257
258#Test tail
259tail -1 f1 >x
260if cmp -s x special; then : ; else echo Error on tail test 1; fi
261
262#Test tsort
263cat >x <<END
264a d
265b e
266c f
267a c
268p z
269k p
270a k
271a b
272b c
273c d
274d e
275e f
276f k
277END
278cat >answer <<END
279a
280b
281c
282d
283e
284f
285k
286p
287z
288END
289tsort <x >y
290if cmp -s y answer; then : ; else echo Error on tsort test 1; fi
291
292#Test uue/uud
293cp $f x
294uue x
295if test -s x.uue; then : ; else echo Error on uue/uud test 1; fi
296rm x
297uud x.uue
298if cmp -s x $f; then : ; else echo Error on uue/uud test 2; fi
299
300compress -fc x >x.Z 2>/dev/null
301uue x.Z
302rm x x.Z
303uud x.uue
304compress -cd x.Z >x
305if cmp -s x $f; then : ; else echo Error on uue/uud test 3; fi
306
307cd ..
308rm -rf DIR_SH1
309
310echo ok
Note: See TracBrowser for help on using the repository browser.