X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=grading%2Fthreads%2Frun-tests;h=d5f58706ec01c2b2d3ba01e4ff70acf2e395600d;hb=1b719c2f3cf8fa5bd7a110345a34e135a790052c;hp=462a1ba0e3330eb783b9914531f2da58b84a96a2;hpb=2f99a0445e1ca3643e6f1157b39e9c6a2bfcc34e;p=pintos-anon diff --git a/grading/threads/run-tests b/grading/threads/run-tests index 462a1ba..d5f5870 100755 --- a/grading/threads/run-tests +++ b/grading/threads/run-tests @@ -89,7 +89,11 @@ if ($grade) { print OUT "$p_got points out of $p_pos total\n\n"; print OUT map ("$_\n", @tests), "\n"; - print OUT map ("$_\n", @review); + print OUT map ("$_\n", @review), "\n"; + + print OUT "DETAILS\n"; + print OUT "-------\n\n"; + print OUT map ("$_\n", snarf ("details.out")); exit 0; } @@ -238,6 +242,17 @@ sub really_run_test { close (CONSTANTS); } + # Changes devices/timer.c if necessary. + my ($new_time_slice) = $test eq 'priority-fifo' ? 100 : 1; + my (@timer) = snarf ("pintos/src/devices/timer.c"); + if (!grep (/^\#define TIME_SLICE $new_time_slice$/, @timer)) { + @timer = grep (!/^\#define TIME_SLICE/, @timer); + unshift (@timer, "#define TIME_SLICE $new_time_slice"); + open (TIMER, ">pintos/src/devices/timer.c"); + print TIMER map ("$_\n", @timer); + close (TIMER); + } + # Copy in the new test.c and delete enough files to ensure a full rebuild. my ($src) = test_source ($test); xsystem ("cp $src pintos/src/threads/test.c", DIE => "cp failed\n"); @@ -592,43 +607,25 @@ sub compare_output { } # They differ. Output a diff. - my ($diff) = ""; + my (@diff) = ""; my ($d) = Algorithm::Diff->new (\@expected, \@actual); - $d->Base (1); while ($d->Next ()) { my ($ef, $el, $af, $al) = $d->Get (qw (min1 max1 min2 max2)); if ($d->Same ()) { - if ($af != $al) { - $diff .= "Actual lines $af...$al match expected lines " - . "$ef...$el.\n"; - } else { - $diff .= "Actual line $af matches expected line $ef.\n"; - } + push (@diff, map (" $_", $d->Items (1))); } else { - my (@i1) = $d->Items (1); - my (@i2) = $d->Items (2); - if (!@i1) { - $diff .= "Extra or misplaced line(s) $af...$al " - . "in actual output:\n"; - $diff .= number_lines ($af, \@i2); - } elsif (!$d->Items (2)) { - $diff .= "Expected line(s) $ef...$el missing or misplaced:\n"; - $diff .= number_lines ($ef, \@i1); - } else { - $diff .= "The following expected line(s) $ef...$el:\n"; - $diff .= number_lines ($ef, \@i1); - $diff .= "became actual line(s) $af...$al:\n"; - $diff .= number_lines ($af, \@i2); - } + push (@diff, map ("- $_", $d->Items (1))) if $d->Items (1); + push (@diff, map ("+ $_", $d->Items (2))) if $d->Items (2); } } my ($details) = ""; - $details .= "$test actual output (line numbers added):\n"; - $details .= number_lines (1, \@actual); - $details .= "\n$test expected output (line numbers added):\n"; - $details .= number_lines (1, \@expected); - $details .= "\n$diff\n"; + $details .= "$test actual output:\n"; + $details .= join ('', map (" $_", @actual)); + $details .= "\n$test expected output:\n"; + $details .= join ('', map (" $_", @expected)); + $details .= "\nOutput differences in `diff -u' format:\n"; + $details .= join ('', @diff) . "\n"; $details{$test} = $details; die "Output differs from expected. Details at end of file.\n"; } @@ -729,6 +726,8 @@ sub xsystem { unlink ("output/$log.err") if defined ($log) && $status == 0; + die $options{DIE} if $status != 0 && defined $options{DIE}; + return $status == 0; }