source: trunk/minix/test/testsh2.sh@ 10

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

Minix 3.1.2a

  • Property svn:executable set to *
File size: 5.3 KB
RevLine 
[9]1#!/bin/sh
2
3# Shell script #2 used to test MINIX.
4
5PATH=:/bin:/usr/bin
6export PATH
7
8# CC="exec cc -wo -F" # nonstandard flags for ACK :-(
9CC=cc
10
11ARCH=`arch`
12
13echo -n "Shell test 2 "
14rm -rf DIR_SH2
15mkdir DIR_SH2 # all files are created here
16cd DIR_SH2
17
18cat >file <<END
19The time has come the walrus said to talk of many things
20Of shoes and ships and sealing wax of cabbages and kings
21Of why the sea is boiling hot and whether pigs have wings
22END
23f=file # scratch file
24
25cat >makefile <<END # create a makefile
26all: x.c
27 @$CC x.c >/dev/null 2>&1
28END
29cat >x.c <<END # create a C program
30#include <stdio.h>
31char s[] = {"MS-DOS: Just say no"}; /* used by strings later */
32main()
33{
34 int i;
35 for (i = 15; i < 18; i++) printf("%d\\n",i*i);
36}
37END
38
39cat >answer <<END # C program should produce these results
40225
41256
42289
43END
44
45make
46if test -f a.out; then : ; else echo Compilation failed; fi
47a.out >x
48if test -f x; then : ; else echo No compiler output; fi
49if cmp -s x answer; then : ; else echo Error in cc test 1; fi
50
51#Test chmod
52echo Hi there folks >x
53if test -r x; then : ; else echo Error on chmod test 1; fi
54chmod 377 x
55if test -r x; then test -w / || echo Error on chmod test 2; fi
56chmod 700 x
57if test -r x; then : ; else echo Error on chmod test 3; fi
58
59#Test cut
60cat >x <<END # x is a test file with 3 columns
611 white bunny
622 gray rabbits
633 brown hares
644 black conies
65END
66
67cat >answer <<END # after cutting out cols 3-7, we get this
68white
69gray
70brown
71black
72END
73
74cut -c 3-7 x >y # extract columns 3-7
75if cmp -s y answer; then : ; else echo Error in cut test 1; fi
76
77#Test dd
78dd if=$f of=x bs=12 count=1 2>/dev/null # x = bytes 0-11
79dd if=$f of=y bs=6 count=4 skip=2 2>/dev/null # y = bytes 11-35
80cat x y >z # z = bytes 0-35
81dd if=$f of=answer bs=9 count=4 2>/dev/null # answer = bytes 0-35
82if cmp -s z answer; then : ; else echo Error in dd test 1; fi
83
84#Test df # hard to make a sensible Test here
85rm ?
86df >x
87if test -r x; then : ; else echo Error in df Test 1; fi
88
89#Test du # see df
90rm ?
91du >x
92if test -r x; then : ; else echo Error in du Test 1; fi
93
94#Test od
95head -1 $f |od >x # see if od converts ascii to octal ok
96if [ $ARCH = i86 -o $ARCH = i386 ]
97then
98cat >answer <<END
990000000 064124 020145 064564 062555 064040 071541 061440 066557
1000000020 020145 064164 020145 060567 071154 071565 071440 064541
1010000040 020144 067564 072040 066141 020153 063157 066440 067141
1020000060 020171 064164 067151 071547 000012
1030000071
104END
105else
106cat >answer <<END
1070000000 052150 062440 072151 066545 020150 060563 020143 067555
1080000020 062440 072150 062440 073541 066162 072563 020163 060551
1090000040 062040 072157 020164 060554 065440 067546 020155 060556
1100000060 074440 072150 064556 063563 005000
1110000071
112END
113fi
114
115if cmp -s x answer; then : ; else echo Error in od test 1; fi
116
117head -1 $f |od -d >x # see if od converts ascii to decimal ok
118if [ $ARCH = i86 -o $ARCH = i386 ]
119then
120cat >answer <<END
1210000000 26708 08293 26996 25965 26656 29537 25376 28015
1220000020 08293 26740 08293 24951 29292 29557 29472 26977
1230000040 08292 28532 29728 27745 08299 26223 27936 28257
1240000060 08313 26740 28265 29543 00010
1250000071
126END
127else
128cat >answer <<END
1290000000 21608 25888 29801 28005 08296 24947 08291 28525
1300000020 25888 29800 25888 30561 27762 30067 08307 24937
1310000040 25632 29807 08308 24940 27424 28518 08301 24942
1320000060 31008 29800 26990 26483 02560
1330000071
134END
135fi
136
137if cmp -s x answer; then : ; else echo Error in od test 2; fi
138
139#Test paste
140cat >x <<END
141red
142green
143blue
144END
145
146cat >y <<END
147rood
148groen
149blauw
150END
151cat >answer <<END
152red rood
153green groen
154blue blauw
155END
156
157paste x y >z
158if cmp -s z answer; then : ; else echo Error in paste test 1; fi
159
160#Test prep
161echo >x <<END
162"Hi," said Carol, laughing, "How's life?"
163END
164
165echo >answer <<END
166hi
167said
168carol
169laughing
170how's
171life
172END
173
174if cmp -s x answer; then : ; else echo Error in prep test 1; fi
175
176#Test printenv
177printenv >x
178if grep HOME x >/dev/null; then : ; else echo Error in printenv test 1; fi
179if grep PATH x >/dev/null; then : ; else echo Error in printenv test 2; fi
180if grep SHELL x >/dev/null; then : ; else echo Error in printenv test 3; fi
181if grep USER x >/dev/null; then : ; else echo Error in printenv test 4; fi
182
183#Test pwd
184pwd >Pwd_file
185cd `pwd`
186pwd >x
187if test -s Pwd_file; then : ; else echo Error in pwd test 1; fi
188if cmp -s Pwd_file x; then : ; else echo Error in pwd test 2; fi
189
190#Test strings
191strings a.out | grep "MS-DOS" >x
192cat >answer <<END
193MS-DOS: Just say no
194END
195
196if cmp -s x answer; then : ; else echo Error in strings test 1; fi
197
198#Test sum
199sum $f >x
200cat >answer <<END
20129904 1
202END
203
204if cmp -s x answer; then : ; else echo Error in sum test 1; fi
205
206#Test tee
207cat $f | tee x >/dev/null
208if cmp -s x $f; then : ; else echo Error in tee test 1; fi
209
210#Test true
211if true ; then : ; else echo Error in true test 1; fi
212
213#Test uniq
214cat >x <<END
215100
216200
217200
218300
219END
220
221cat >answer <<END
222100
223200
224300
225END
226
227uniq <x >y
228if cmp -s y answer; then : ; else echo Error in uniq test 1; fi
229
230#Test pipelines
231cat >x <<END
232the big black dog
233the little white cat
234the big white sheep
235the little black cat
236END
237
238cat >answer <<END
239 1 dog
240 1 sheep
241 2 big
242 2 black
243 2 cat
244 2 little
245 2 white
246 4 the
247END
248
249prep x | sort | uniq -c >y1
250sort +1 <y1 >y
251if cmp -s y answer; then : ; else echo Error in pipeline test 1; fi
252
253cat $f $f $f | sort | uniq >x
254sort <$f >y
255if cmp -s x y; then : ; else echo Error in pipeline test 2; fi
256
257cd ..
258rm -rf DIR_SH2
259
260echo ok
Note: See TracBrowser for help on using the repository browser.