}
# 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
+ ) unless @TESTS > 0;
our (%args);
for my $key ('args-argc', 'args-argv0', 'args-argvn', 'args-multiple') {
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+$/;
return "ok";
}
\f
-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);
- }
- }
- @products = sort {$a <=> $b} @products;
-
- local ($_);
- foreach (@output) {
- die $_ if /Out of order/;
-
- my ($p) = /product=(\d+)$/;
- next if !defined $p;
-
- 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 scalar (@products) . " fewer wakeups than expected.\n"
- if @products != 0;
+ 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;
+ compare_output ("$GRADES_DIR/sample.txt", snarf ($test_txt));
}
-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 {
# 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 ()) {
} 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);