From: Ben Pfaff Date: Wed, 24 Nov 2004 00:41:12 +0000 (+0000) Subject: Update tests. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=683215cdf85a8c5c4455dda1c305d3f597ebef60;p=pintos-anon Update tests. --- diff --git a/grading/vm/mmap-twice.c b/grading/vm/mmap-twice.c index f913d1d..aba5ef2 100644 --- a/grading/vm/mmap-twice.c +++ b/grading/vm/mmap-twice.c @@ -21,12 +21,12 @@ main (void) fd[i] = open ("sample.txt"); if (fd[i] < 0) { - printf ("(mmap-twice) open() %zu failed\n", i); + printf ("(mmap-twice) open() #%zu failed\n", i); return 1; } if (!mmap (fd[i], actual[i], 8192)) { - printf ("(mmap-twice) mmap() %zu failed\n", i); + printf ("(mmap-twice) mmap() #%zu failed\n", i); return 1; } } diff --git a/grading/vm/mmap-unmap.c b/grading/vm/mmap-unmap.c index fcdff70..2ab3eea 100644 --- a/grading/vm/mmap-unmap.c +++ b/grading/vm/mmap-unmap.c @@ -31,7 +31,7 @@ main (void) munmap (ACTUAL, strlen (sample)); - printf ("(mmap-unmap) fail: unmapped memory is readable (%d)\n", + printf ("(mmap-unmap) FAIL: unmapped memory is readable (%d)\n", *(int *) ACTUAL); /* Done. */ diff --git a/grading/vm/mmap-unmap.exp b/grading/vm/mmap-unmap.exp deleted file mode 100644 index 178805d..0000000 --- a/grading/vm/mmap-unmap.exp +++ /dev/null @@ -1 +0,0 @@ -(mmap-unmap) begin diff --git a/grading/vm/pt-bad-addr.c b/grading/vm/pt-bad-addr.c index 6d66587..96a54ee 100644 --- a/grading/vm/pt-bad-addr.c +++ b/grading/vm/pt-bad-addr.c @@ -4,7 +4,7 @@ int main (void) { printf ("(pt-bad-addr) begin\n"); - printf ("(pt-bad-addr) addr=%d\n", *(int *) 0x04000000); + printf ("(pt-bad-addr) FAIL: bad addr read as %d\n", *(int *) 0x04000000); printf ("(pt-bad-addr) end\n"); return 0; } diff --git a/grading/vm/pt-bad-addr.exp b/grading/vm/pt-bad-addr.exp deleted file mode 100644 index 593835e..0000000 --- a/grading/vm/pt-bad-addr.exp +++ /dev/null @@ -1 +0,0 @@ -(pt-bad-addr) begin diff --git a/grading/vm/pt-write-code.c b/grading/vm/pt-write-code.c index 1b9b4a8..a661c15 100644 --- a/grading/vm/pt-write-code.c +++ b/grading/vm/pt-write-code.c @@ -5,7 +5,7 @@ main (void) { printf ("(pt-write-code) begin\n"); *(int *) main = 0; - printf ("(pt-write code) fail: writing the code segment succeeded\n"); + printf ("(pt-write code) FAIL: writing the code segment succeeded\n"); printf ("(pt-write-code) end\n"); return 0; } diff --git a/grading/vm/pt-write-code.exp b/grading/vm/pt-write-code.exp deleted file mode 100644 index f048fc6..0000000 --- a/grading/vm/pt-write-code.exp +++ /dev/null @@ -1 +0,0 @@ -(pt-write-code) begin diff --git a/grading/vm/review.txt b/grading/vm/review.txt index 82a30f0..ad81e4f 100644 --- a/grading/vm/review.txt +++ b/grading/vm/review.txt @@ -16,7 +16,6 @@ DESIGNDOC (per problem): -5 Doesn't explain how memory mapping works Overall: - -3 Holds a global lock while accessing the disk -1 Gratuitous use of malloc() (e.g. for allocating a list or a lock) -1 Inappropriate use of ASSERT (e.g. to verify that malloc() succeeded) diff --git a/grading/vm/run-tests b/grading/vm/run-tests index 161a6a8..f74bd99 100755 --- a/grading/vm/run-tests +++ b/grading/vm/run-tests @@ -298,86 +298,30 @@ sub grade_test { return "ok"; } -sub grade_write_normal { - my (@output) = @_; - verify_common (@output); - compare_output ("$GRADES_DIR/write-normal.exp", @output); - my ($test_txt) = "output/$test/test.txt"; - get_file ("test.txt", $test_txt) if ! -e $test_txt; - - my (@actual) = snarf ($test_txt); - my (@expected) = snarf ("$GRADES_DIR/sample.txt"); - - my ($eq); - if ($#actual == $#expected) { - $eq = 1; - for my $i (0...$#actual) { - $eq = 0 if $actual[$i] ne $expected[$i]; - } - } else { - $eq = 0; - } - if (!$eq) { - my ($details); - $details = "Expected file content:\n"; - $details .= join ('', map (" $_\n", @expected)); - $details .= "Actual file content:\n"; - $details .= join ('', map (" $_\n", @actual)); - $extra{$test} = $details; - - die "File written didn't have expected content.\n"; - } -} +sub grade_process_death { + my ($proc_name, @output) = @_; -sub grade_multi_oom { - my (@output) = @_; verify_common (@output); + @output = get_core_output (@output); + die "First line of output is not `($proc_name) begin' message.\n" + if $output[0] ne "($proc_name) begin"; + die "Output contains `FAIL' message.\n" + if grep (/FAIL/, @output); + die "Output contains spurious ($proc_name) message.\n" + if grep (/\($proc_name\)/, @output) > 1; +} - @output = fix_exit_codes (get_core_output (@output)); - my ($n) = 0; - while (my ($m) = $output[0] =~ /^\(multi-oom\) begin (\d+)$/) { - die "Child process $m started out of order.\n" if $m != $n; - $n = $m + 1; - shift @output; - } - die "Only $n child process(es) 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: exit\(-1\)$/ - || $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 !/^\(multi-oom\) end $n$/; - - 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; +sub grade_pt_bad_addr { + grade_process_death ('pt-bad-addr', @_); } -sub get_file { - my ($guest_fn, $host_fn) = @_; - xsystem ("pintos " - . "--os-disk=pintos/src/vm/build/os.dsk " - . "--fs-disk=output/$test/fs.dsk " - . "-v get $guest_fn $host_fn", - LOG => "$test/get-$guest_fn", - TIMEOUT => 10) - or die "get $guest_fn failed\n"; +sub grade_pt_write_code { + grade_process_death ('pt-write-code', @_); } +sub grade_mmap_unmap { + grade_process_death ('mmap-unmap', @_); +} sub verify_common { my (@output) = @_;