projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Be smarter about dealing with make failures.
[pintos-anon]
/
grading
/
lib
/
Pintos
/
Grading.pm
diff --git
a/grading/lib/Pintos/Grading.pm
b/grading/lib/Pintos/Grading.pm
index c2072a4f1c4714eb85a5f00e168f259c9698f4b5..f29dc05f7c9ae494682c0ea49eb0f99ea2a5d22d 100644
(file)
--- a/
grading/lib/Pintos/Grading.pm
+++ b/
grading/lib/Pintos/Grading.pm
@@
-316,7
+316,13
@@
sub xsystem {
open (STDOUT, ">output/$log.out");
open (STDERR, ">output/$log.err");
}
open (STDOUT, ">output/$log.out");
open (STDERR, ">output/$log.err");
}
- exec ($command);
+ chdir $options{CHDIR} or die "$options{CHDIR}: chdir: $!\n"
+ if defined ($options{CHDIR});
+ if (!defined ($options{EXEC})) {
+ exec ($command);
+ } else {
+ exec (@{$options{EXEC}});
+ }
exit (-1);
}
waitpid ($pid, 0);
exit (-1);
}
waitpid ($pid, 0);
@@
-345,12
+351,9
@@
sub xsystem {
print "Child terminated with signal $signal\n";
}
print "Child terminated with signal $signal\n";
}
- my ($exp_status) = !defined ($options{EXPECT}) ? 0 : $options{EXPECT};
- $result = WIFEXITED ($status) && WEXITSTATUS ($status) == $exp_status
- ? "ok" : "error";
+ $result = $status == 0 ? "ok" : "error";
}
}
-
if ($result eq 'error' && defined $options{DIE}) {
my ($msg) = $options{DIE};
if (defined ($log)) {
if ($result eq 'error' && defined $options{DIE}) {
my ($msg) = $options{DIE};
if (defined ($log)) {
@@
-402,10
+405,15
@@
sub get_test_result {
sub run_pintos {
my ($cmd_line, %args) = @_;
sub run_pintos {
my ($cmd_line, %args) = @_;
-
$args{EXPECT} = 1 unless defined $args{EXPECT}
;
- my ($retval) = xsystem (
$cmd_line, %args
);
+
unshift (@$cmd_line, 'pintos')
;
+ my ($retval) = xsystem (
join (' ', @$cmd_line), %args, EXEC => $cmd_line
);
return 'ok' if $retval eq 'ok';
return 'ok' if $retval eq 'ok';
- return "Timed out after $args{TIMEOUT} seconds" if $retval eq 'timeout';
+ if ($retval eq 'timeout') {
+ my ($msg) = "Timed out after $args{TIMEOUT} seconds";
+ my ($load_avg) = `uptime` =~ /(load average:.*)$/i;
+ $msg .= " - $load_avg" if defined $load_avg;
+ return $msg;
+ }
return 'Error running Bochs' if $retval eq 'error';
die;
}
return 'Error running Bochs' if $retval eq 'error';
die;
}
@@
-414,7
+422,14
@@
sub run_pintos {
sub grade_test {
# Read test output.
my ($outfile) = "output/$test/run.out";
sub grade_test {
# Read test output.
my ($outfile) = "output/$test/run.out";
- die "$outfile: missing test output file (make failed?)" if ! -e $outfile;
+ if (! -e $outfile) {
+ if (-s "output/$test.make.err") {
+ # make failed.
+ $details{$test} = snarf ("output/$test.make.err");
+ return "make failed. Error messages at end of file.";
+ }
+ die "$outfile: missing test output file";
+ }
my (@output) = snarf ($outfile);
# If there's a function "grade_$test", use it to evaluate the output.
my (@output) = snarf ($outfile);
# If there's a function "grade_$test", use it to evaluate the output.
@@
-832,5
+847,12
@@
sub file_contains {
close (FILE);
return $equal;
}
close (FILE);
return $equal;
}
+
\f
+sub success {
+ for my $test (@TESTS) {
+ return 1 if !defined ($result{$test}) || $result{$test} ne 'ok';
+ }
+ return 0;
+}
1;
1;