pgdir_walk, boot_map_segment, page_{lookup,remove,insert} implemented.
[mit-jos.git] / grade.sh
blob34005b9d70a13509ab5c8f9ad8505792d3209b93
1 #!/bin/sh
3 verbose=false
5 if [ "x$1" = "x-v" ]
6 then
7 verbose=true
8 out=/dev/stdout
9 err=/dev/stderr
10 else
11 out=/dev/null
12 err=/dev/null
15 pts=5
16 timeout=30
17 preservefs=n
19 echo_n () {
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
25 runbochs () {
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
39 sleep .5
40 echo c
41 # EOF will do just fine to quit.
42 ) | (
43 ulimit -t $timeout
44 # date
45 bochs -q 'display_library: nogui' \
46 'parport1: enabled=1, file="bochs.out"'
47 # date
48 ) >$out 2>$err
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`
51 time="(${time}s)"
56 gmake
57 runbochs
59 score=0
61 echo_n "Page directory: "
62 if grep "check_boot_pgdir() succeeded!" bochs.out >/dev/null
63 then
64 score=`expr 20 + $score`
65 echo OK $time
66 else
67 echo WRONG $time
70 echo_n "Page management: "
71 if grep "page_check() succeeded!" bochs.out >/dev/null
72 then
73 score=`expr 30 + $score`
74 echo OK $time
75 else
76 echo WRONG $time
79 echo "Score: $score/50"
81 if [ $score -lt 50 ]; then
82 exit 1