From: Ben Pfaff Date: Thu, 4 Nov 2004 01:22:23 +0000 (+0000) Subject: Improve run-tests to accept more output code formats. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c893972febefec473748d49cb65e9719b3cf5d80;p=pintos-anon Improve run-tests to accept more output code formats. Fix some tests. --- diff --git a/grading/userprog/.cvsignore b/grading/userprog/.cvsignore index 73d1273..602fcbd 100644 --- a/grading/userprog/.cvsignore +++ b/grading/userprog/.cvsignore @@ -1,2 +1,58 @@ +# Automatically generated by mkmf - do not modify! *.d *.dsk +*.o +args-argc +args-argv0 +args-argvn +args-single +args-multiple +args-dbl-space +sc-bad-sp +sc-bad-arg +sc-boundary +halt +exit +create-normal +create-empty +create-null +create-bad-ptr +create-long +create-exists +create-bound +open-normal +open-missing +open-boundary +open-empty +open-null +open-bad-ptr +open-twice +close-normal +close-twice +close-stdin +close-stdout +close-bad-fd +read-normal +read-bad-ptr +read-boundary +read-zero +read-stdout +read-bad-fd +write-normal +write-bad-ptr +write-boundary +write-zero +write-stdin +write-bad-fd +exec-once +exec-arg +exec-multiple +exec-missing +exec-bad-ptr +join-simple +join-twice +join-killed +join-bad-pid +multi-recurse +multi-oom +multi-child-fd diff --git a/grading/userprog/exec-missing.exp b/grading/userprog/exec-missing.exp index 7334b9e..5667040 100644 --- a/grading/userprog/exec-missing.exp +++ b/grading/userprog/exec-missing.exp @@ -1,4 +1,12 @@ (exec-missing) begin +load: no-such-file: open failed +(exec-missing) exec("no-such-file"): -1 +(exec-missing) end +exec-missing: exit(0) +--OR-- +(exec-missing) begin +load: no-such-file: open failed +no-such-file: exit(-1) (exec-missing) exec("no-such-file"): -1 (exec-missing) end exec-missing: exit(0) diff --git a/grading/userprog/join-bad-pid.exp b/grading/userprog/join-bad-pid.exp index 0446482..2f7f5ee 100644 --- a/grading/userprog/join-bad-pid.exp +++ b/grading/userprog/join-bad-pid.exp @@ -1,4 +1,6 @@ -(join-simple) begin -(join-simple) join(exec()) = 81 -(join-simple) end -join-simple: exit(0) +(join-bad-pid) begin +(join-bad-pid) end +join-bad-pid: exit(0) +--OR-- +(join-bad-pid) begin +join-bad-pid: exit(-1) diff --git a/grading/userprog/join-twice.c b/grading/userprog/join-twice.c index 10ccb22..2a80ad7 100644 --- a/grading/userprog/join-twice.c +++ b/grading/userprog/join-twice.c @@ -6,7 +6,7 @@ main (void) { pid_t child; printf ("(join-twice) begin\n"); - child = exec ("child-twice"); + child = exec ("child-simple"); printf ("(join-twice) join(exec()) = %d\n", join (child)); join (child); printf ("(join-twice) end\n"); diff --git a/grading/userprog/join-twice.exp b/grading/userprog/join-twice.exp index 71f6223..ffb57ea 100644 --- a/grading/userprog/join-twice.exp +++ b/grading/userprog/join-twice.exp @@ -1,6 +1,6 @@ (join-twice) begin -(child-twice) run -child-twice: exit(81) +(child-simple) run +child-simple: exit(81) (join-twice) join(exec()) = 81 (join-twice) end join-twice: exit(0) diff --git a/grading/userprog/mkmf b/grading/userprog/mkmf index a45ee56..7cfeae8 100755 --- a/grading/userprog/mkmf +++ b/grading/userprog/mkmf @@ -46,3 +46,12 @@ while () { } close (MAKEBASE); +open (CVSIGNORE, ">.cvsignore"); +print CVSIGNORE < 0; @@ -347,16 +348,28 @@ sub grade_multi_oom { shift @output; } die "Only $n child processes started.\n" if $n < 15; + + # There could be a death notice for a process that didn't get + # fully loaded, and/or notices from the loader. + while (@output > 0 + && ($output[0] =~ /^\(multi-oom\) end $n$/ + || $output[0] =~ /^load: /)) { + shift @output; + } + while (--$n >= 0) { die "Output ended unexpectedly before process $n finished.\n" if @output < 2; + + local ($_); + chomp ($_ = shift @output); + die "Found '$_' expecting 'end' message.\n" if !/^\(multi-oom\) end/; die "Child process $n ended out of order.\n" - if $output[0] !~ /^\(multi-oom\) end $n$/; - shift @output; + if !/^\(multi-oom\) end $n$/; - die "Child process $n didn't print proper exit message.\n" - if $output[0] !~ /^multi-oom: exit\($n\)$/; - shift @output; + chomp ($_ = shift @output); + die "Kernel didn't print proper exit message for process $n.\n" + if !/^multi-oom: exit\($n\)$/; } die "Spurious output at end: '$output[0]'.\n" if @output; } @@ -446,9 +459,18 @@ sub fix_exit_codes { my (@output) = @_; # Fix up lines that look like exit codes. + # Exit codes are supposed to be printed in the form "process: exit(code)" + # but people get unfortunately creative with it. for my $i (0...$#output) { - if (my ($process, $code) - = $output[$i] =~ /^([-a-zA-Z0-9 ]+):.*[ \(](-?\d+)\b\)?$/) { + local ($_) = $output[$i]; + + my ($process, $code); + if ((($process, $code) = /^([-a-zA-Z0-9 ]+):.*[ \(](-?\d+)\b\)?$/) + || (($process, $code) = /^([-a-zA-Z0-9 ]+) exit\((-?\d+)\)$/) + || (($process, $code) + = /^([-a-zA-Z0-9 ]+) \(.*\): exit\((-?\d+)\)$/) + || (($process, $code) = /^([-a-zA-Z0-9 ]+):\( (-?\d+) \) $/) +) { $process = substr ($process, 0, 15); $process =~ s/\s.*//; $output[$i] = "$process: exit($code)\n"; @@ -510,7 +532,8 @@ sub compare_output { $details .= "Differences in `diff -u' format:\n"; $details .= join ('', @diff); - $details .= "(This is considered a `fuzzy match'.)\n" if $fuzzy_match; + $details .= "(This is considered a `fuzzy match'.)\n" + if !$not_fuzzy_match; } $details{$test} = $details;