VM: memtype fix
[minix3.git] / test / testsh2.sh
blob0a30b420f64630cd87a576ca6b1f924332c61719
1 #!/bin/sh
3 # Shell script #2 used to test MINIX.
5 # Helper function
6 bomb() {
7 echo $*
8 cd ..
9 rm -rf $TESTDIR
10 exit 1
13 PATH=:/bin:/usr/bin:/usr/pkg/bin
14 export PATH
16 TESTDIR=DIR_SH2
17 export TESTDIR
19 OLDPWD=`pwd`
20 export OLDPWD
22 # CC="exec cc -wo -F" # nonstandard flags for ACK :-(
23 CC=clang
25 ARCH=`arch`
27 echo -n "Shell test 2 "
28 rm -rf $TESTDIR
29 mkdir $TESTDIR # all files are created here
30 cd $TESTDIR
32 cat >file <<END
33 The time has come the walrus said to talk of many things
34 Of shoes and ships and sealing wax of cabbages and kings
35 Of why the sea is boiling hot and whether pigs have wings
36 END
37 f=file # scratch file
39 cat >makefile <<END # create a makefile
40 all: x.c
41 @$CC x.c >/dev/null 2>&1
42 END
43 cat >x.c <<END # create a C program
44 #include <stdio.h>
45 char s[] = {"MS-DOS: Just say no"}; /* used by strings later */
46 main()
48 int i;
49 for (i = 15; i < 18; i++) printf("%d\\n",i*i);
51 END
53 cat >answer <<END # C program should produce these results
54 225
55 256
56 289
57 END
59 make
60 if test -f a.out; then : ; else bomb "Compilation failed"; fi
61 a.out >x
62 if test -f x; then : ; else bomb "No compiler output"; fi
63 if cmp -s x answer; then : ; else bomb "Error in cc test 1"; fi
65 #Test chmod
66 echo "Hi there folks" >x
67 if test -r x; then : ; else bomb "Error on chmod test 1"; fi
68 chmod 377 x
69 if test -r x; then test -w / || bomb "Error on chmod test 2"; fi
70 chmod 700 x
71 if test -r x; then : ; else bomb "Error on chmod test 3"; fi
73 #Test cut
74 cat >x <<END # x is a test file with 3 columns
75 1 white bunny
76 2 gray rabbits
77 3 brown hares
78 4 black conies
79 END
81 cat >answer <<END # after cutting out cols 3-7, we get this
82 white
83 gray
84 brown
85 black
86 END
88 cut -c 3-7 x >y # extract columns 3-7
89 if cmp -s y answer; then : ; else bomb "Error in cut test 1"; fi
91 #Test dd
92 dd if=$f of=x bs=12 count=1 2>/dev/null # x = bytes 0-11
93 dd if=$f of=y bs=6 count=4 skip=2 2>/dev/null # y = bytes 11-35
94 cat x y >z # z = bytes 0-35
95 dd if=$f of=answer bs=9 count=4 2>/dev/null # answer = bytes 0-35
96 if cmp -s z answer; then : ; else bomb "Error in dd test 1"; fi
98 #Test df # hard to make a sensible Test here
99 rm ?
100 df >x
101 if test -r x; then : ; else bomb "Error in df Test 1"; fi
103 #Test du # see df
104 rm ?
105 du >x
106 if test -r x; then : ; else bomb "Error in du Test 1"; fi
108 #Test od
109 head -1 $f |od >x # see if od converts ascii to octal ok
110 if [ $ARCH = i86 -o $ARCH = i386 ]
111 then
112 cat >answer <<END
113 0000000 064124 020145 064564 062555 064040 071541 061440 066557
114 0000020 020145 064164 020145 060567 071154 071565 071440 064541
115 0000040 020144 067564 072040 066141 020153 063157 066440 067141
116 0000060 020171 064164 067151 071547 000012
117 0000071
119 else
120 cat >answer <<END
121 0000000 052150 062440 072151 066545 020150 060563 020143 067555
122 0000020 062440 072150 062440 073541 066162 072563 020163 060551
123 0000040 062040 072157 020164 060554 065440 067546 020155 060556
124 0000060 074440 072150 064556 063563 005000
125 0000071
129 if cmp -s x answer; then : ; else bomb "Error in od test 1"; fi
131 head -1 $f |od -d >x # see if od converts ascii to decimal ok
132 if [ $ARCH = i86 -o $ARCH = i386 ]
133 then
134 cat >answer <<END
135 0000000 26708 08293 26996 25965 26656 29537 25376 28015
136 0000020 08293 26740 08293 24951 29292 29557 29472 26977
137 0000040 08292 28532 29728 27745 08299 26223 27936 28257
138 0000060 08313 26740 28265 29543 00010
139 0000071
141 else
142 cat >answer <<END
143 0000000 21608 25888 29801 28005 08296 24947 08291 28525
144 0000020 25888 29800 25888 30561 27762 30067 08307 24937
145 0000040 25632 29807 08308 24940 27424 28518 08301 24942
146 0000060 31008 29800 26990 26483 02560
147 0000071
151 if cmp -s x answer; then : ; else bomb "Error in od test 2"; fi
153 #Test paste
154 cat >x <<END
156 green
157 blue
160 cat >y <<END
161 rood
162 groen
163 blauw
165 cat >answer <<END
166 red rood
167 green groen
168 blue blauw
171 paste x y >z
172 if cmp -s z answer; then : ; else bomb "Error in paste test 1"; fi
174 #Test prep
175 prep >x <<END
176 "Hi," said Carol, laughing, "How's life?"
179 cat >answer <<END
181 said
182 carol
183 laughing
184 how's
185 life
188 if cmp -s x answer; then : ; else bomb "Error in prep test 1"; fi
190 #Test printenv
191 printenv >x
192 if grep HOME x >/dev/null; then : ; else bomb "Error in printenv test 1"; fi
193 if grep PATH x >/dev/null; then : ; else bomb "Error in printenv test 2"; fi
194 if grep SHELL x >/dev/null; then : ; else bomb "Error in printenv test 3"; fi
195 if grep USER x >/dev/null; then : ; else bomb "Error in printenv test 4"; fi
197 #Test pwd
198 pwd >Pwd_file
199 cd `pwd`
200 pwd >x
201 if test -s Pwd_file; then : ; else bomb "Error in pwd test 1"; fi
202 if cmp -s Pwd_file x; then : ; else bomb "Error in pwd test 2"; fi
204 #Test strings
205 strings a.out | grep "MS-DOS" >x
206 cat >answer <<END
207 MS-DOS: Just say no
210 if cmp -s x answer; then : ; else bomb "Error in strings test 1"; fi
212 #Test sum
213 sum $f >x
214 cat >answer <<END
215 29904 1 $f
218 if cmp -s x answer; then : ; else bomb "Error in sum test 1"; fi
220 #Test tee
221 cat $f | tee x >/dev/null
222 if cmp -s x $f; then : ; else bomb "Error in tee test 1"; fi
224 #Test true
225 if true ; then : ; else bomb "Error in true test 1"; fi
227 #Test uniq
228 cat >x <<END
235 cat >answer <<END
241 uniq <x >y
242 if cmp -s y answer; then : ; else bomb "Error in uniq test 1"; fi
244 #Test pipelines
245 cat >x <<END
246 the big black dog
247 the little white cat
248 the big white sheep
249 the little black cat
252 cat >answer <<END
253 1 dog
254 1 sheep
255 2 big
256 2 black
257 2 cat
258 2 little
259 2 white
260 4 the
263 prep x | sort | uniq -c >y1
264 sort <y1 >y
265 if cmp -s y answer; then : ; else bomb "Error in pipeline test 1"; fi
267 cat $f $f $f | sort | uniq >x
268 sort <$f >y
269 if cmp -s x y; then : ; else bomb "Error in pipeline test 2"; fi
271 cd ..
272 rm -rf $TESTDIR
274 echo ok