20 # suns can't echo -n, and Mac OS X can't echo "x\c"
21 # assume argument has no doublequotes
22 awk 'BEGIN { printf("'"$*"'"); }' </dev
/null
26 # Find the address of the kernel readline function,
27 # which the kernel monitor uses to read commands interactively.
28 brkaddr
=`grep 'readline$' obj/kern/kernel.sym | sed -e's/ .*$//g'`
29 #echo "brkaddr $brkaddr"
31 # Run Bochs, setting a breakpoint at readline(),
32 # and feeding in appropriate commands to run, then quit.
33 t0
=`date +%s.%N 2>/dev/null`
35 # The sleeps are necessary in some Bochs to
36 # make it parse each line separately. Sleeping
37 # here sure beats waiting for the timeout.
38 echo vbreak
0x8:0x
$brkaddr
41 # EOF will do just fine to quit.
45 bochs
-q 'display_library: nogui' \
46 'parport1: enabled=1, file="bochs.out"'
49 t1
=`date +%s.%N 2>/dev/null`
50 time=`echo "scale=1; ($t1-$t0)/1" | sed 's/.N/.0/g' | bc 2>/dev/null`
54 # Usage: runtest <tagname> <defs> <strings...>
56 perl
-e "print '$1: '"
57 rm -f obj
/kern
/init.o obj
/kern
/kernel obj
/kern
/bochs.img
58 [ "$preservefs" = y
] ||
rm -f obj
/fs
/fs.img
81 perl
-e "print '$1: '"
87 perl
-e "print qq|$1: OK $2\n|";
89 score
=`expr $pts + $score`
103 if egrep "^$i\$" bochs.out
>/dev
/null
105 echo "got unexpected line '$i'"
114 egrep "^$i\$" bochs.out
>/dev
/null
127 if [ "$okay" = "yes" ]
129 score
=`expr $pts + $score`
136 # Usage: runtest1 [-tag <tagname>] <progname> [-Ddef...] STRINGS...
151 while expr "x$1" : 'x-D.*' >/dev
/null
; do
152 runtest1_defs
="DEFS+='$1' $runtest1_defs"
155 runtest
"$tag" "DEFS='-DTEST=_binary_obj_user_${prog}_start' DEFS+='-DTESTSIZE=_binary_obj_user_${prog}_size' $runtest1_defs" "$@"
162 '.00000000. new env 00001000' \
163 '.00000000. new env 00001001' \
164 '0: I am the parent!' \
165 '9: I am the parent!' \
166 '0: I am the child!' \
167 '9: I am the child!' \
168 '19: I am the child!' \
169 '.00001001. exiting gracefully' \
170 '.00001001. free env 00001001' \
171 '.00001002. exiting gracefully' \
172 '.00001002. free env 00001002'
174 echo PART A SCORE
: $score/5
177 ! 'I read ........ from location 0!' \
178 '.00001001. user fault va 00000000 ip 008.....' \
179 'TRAP frame at 0xf.......' \
180 ' trap 0x0000000e Page Fault' \
182 '.00001001. free env 00001001'
184 runtest1 faultwrite \
185 '.00001001. user fault va 00000000 ip 008.....' \
186 'TRAP frame at 0xf.......' \
187 ' trap 0x0000000e Page Fault' \
189 '.00001001. free env 00001001'
192 'i faulted at va deadbeef, err 6' \
193 '.00001001. exiting gracefully' \
194 '.00001001. free env 00001001'
196 runtest1 faultalloc \
198 'this string was faulted in at deadbeef' \
201 'this string was faulted in at cafebffe' \
202 '.00001001. exiting gracefully' \
203 '.00001001. free env 00001001'
205 runtest1 faultallocbad \
206 '.00001001. user_mem_check assertion failure for va deadbeef' \
207 '.00001001. free env 00001001'
209 runtest1 faultnostack \
210 '.00001001. user_mem_check assertion failure for va eebfff..' \
211 '.00001001. free env 00001001'
213 runtest1 faultbadhandler \
214 '.00001001. user_mem_check assertion failure for va (deadb|eebfe)...' \
215 '.00001001. free env 00001001'
217 runtest1 faultevilhandler \
218 '.00001001. user_mem_check assertion failure for va (f0100|eebfe)...' \
219 '.00001001. free env 00001001'
230 '.00001001. exiting gracefully' \
231 '.00001002. exiting gracefully' \
232 '.0000200.. exiting gracefully' \
233 '.0000200.. free env 0000200.'
235 echo PART B SCORE
: $score/50
238 '.00000000. new env 00001000' \
239 '.00000000. new env 00001001' \
240 'I am the parent. Forking the child...' \
241 '.00001001. new env 00001002' \
242 'I am the parent. Running the child...' \
243 'I am the child. Spinning...' \
244 'I am the parent. Killing the child...' \
245 '.00001001. destroying 00001002' \
246 '.00001001. free env 00001002' \
247 '.00001001. exiting gracefully' \
248 '.00001001. free env 00001001'
251 '.00000000. new env 00001000' \
252 '.00000000. new env 00001001' \
253 '.00001001. new env 00001002' \
254 'send 0 from 1001 to 1002' \
255 '1002 got 0 from 1001' \
256 '1001 got 1 from 1002' \
257 '1002 got 8 from 1001' \
258 '1001 got 9 from 1002' \
259 '1002 got 10 from 1001' \
260 '.00001001. exiting gracefully' \
261 '.00001001. free env 00001001' \
262 '.00001002. exiting gracefully' \
263 '.00001002. free env 00001002' \
266 '.00000000. new env 00001000' \
267 '.00000000. new env 00001001' \
268 '.00001001. new env 00001002' \
269 '2 .00001002. new env 00001003' \
270 '3 .00001003. new env 00001004' \
271 '5 .00001004. new env 00001005' \
272 '7 .00001005. new env 00001006' \
273 '11 .00001006. new env 00001007'
275 echo PART C SCORE
: $score/65
277 if [ $score -lt 65 ]; then