X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=grading%2Fuserprog%2Frun-tests;h=c51089eb023234a0e95910851995b5d8100cb0fb;hb=2e2f580dd9eb1a8fa094e35f4b967e2547774d9c;hp=e7a31acb5f06190369f9329b880a4e5623282da8;hpb=68cfbad945e00d12f3ac8f0fa33664ad2caa0eee;p=pintos-anon diff --git a/grading/userprog/run-tests b/grading/userprog/run-tests index e7a31ac..c51089e 100755 --- a/grading/userprog/run-tests +++ b/grading/userprog/run-tests @@ -37,11 +37,21 @@ sub usage { } # Default set of tests. -@TESTS = qw (create-normal create-empty create-null create-bad-ptr +@TESTS = qw (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 - args-argc args-argv0 args-argvn args-single args-multiple - args-dbl-space) - unless @TESTS > 0; + 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 + ) unless @TESTS > 0; our (%args); for my $key ('args-argc', 'args-argv0', 'args-argvn', 'args-multiple') { @@ -264,15 +274,15 @@ sub grade_test { my (@output) = snarf ("output/$test/run.out"); - if (-e "$GRADES_DIR/$test.exp") { + my ($grade_func) = "grade_$test"; + $grade_func =~ s/-/_/g; + if (-e "$GRADES_DIR/$test.exp" && !defined (&$grade_func)) { eval { verify_common (@output); compare_output ("$GRADES_DIR/$test.exp", @output); } } else { - my ($grade_func); - ($grade_func = $test) =~ s/-/_/g; - eval "grade_$grade_func (\@output)"; + eval "$grade_func (\@output)"; } if ($@) { die $@ if $@ =~ /at \S+ line \d+$/; @@ -281,42 +291,46 @@ sub grade_test { return "ok"; } -sub grade_alarm_multiple { - verify_alarm (7, @_); -} - -sub verify_alarm { - my ($iterations, @output) = @_; - +sub grade_write_normal { + my (@output) = @_; verify_common (@output); - - my (@products); - for (my ($i) = 0; $i < $iterations; $i++) { - for (my ($t) = 0; $t < 5; $t++) { - push (@products, ($i + 1) * ($t + 1) * 10); + 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; } - @products = sort {$a <=> $b} @products; - - local ($_); - foreach (@output) { - die $_ if /Out of order/; - - my ($p) = /product=(\d+)$/; - next if !defined $p; + 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; - my ($q) = shift (@products); - die "Too many wakeups.\n" if !defined $q; - die "Out of order wakeups ($p vs. $q).\n" if $p != $q; # FIXME + die "File written didn't have expected content.\n"; } - die scalar (@products) . " fewer wakeups than expected.\n" - if @products != 0; } -sub grade_alarm_zero { - my (@output) = @_; - verify_common (@output); - die "Crashed in timer_sleep()\n" if !grep (/^Success\.$/, @output); +sub get_file { + my ($guest_fn, $host_fn) = @_; + xsystem ("pintos " + . "--os-disk=pintos/src/userprog/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_alarm_negative { @@ -623,7 +637,7 @@ sub compare_output { # They differ. Output a diff. my (@diff) = ""; my ($d) = Algorithm::Diff->new (\@expected, \@actual); - my ($all_additions) = 1; + my ($not_fuzzy_match) = 0; while ($d->Next ()) { my ($ef, $el, $af, $al) = $d->Get (qw (min1 max1 min2 max2)); if ($d->Same ()) { @@ -631,11 +645,13 @@ sub compare_output { } else { push (@diff, map ("- $_", $d->Items (1))) if $d->Items (1); push (@diff, map ("+ $_", $d->Items (2))) if $d->Items (2); - $all_additions = 0 if $d->Items (1); + if ($d->Items (1) + || grep (/\($test\)|exit\(-?\d+\)/, $d->Items (2))) { + $not_fuzzy_match = 1; + } } } - - $fuzzy_match = 1 if $all_additions; + $fuzzy_match = 1 if !$not_fuzzy_match; $details .= "Differences in `diff -u' format:\n"; $details .= join ('', @diff);