X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=grading%2Flib%2FPintos%2FGrading.pm;h=ad2a8259ea85a88683357e883895ea5a6ed02c04;hb=05a5604be6df472e30d2495d3187259da2e380b8;hp=860720c0750e3bf5e6a526e431bbb9cad04c56c8;hpb=8176d4bd89c45d3b18a3240728ec650d822ab835;p=pintos-anon diff --git a/grading/lib/Pintos/Grading.pm b/grading/lib/Pintos/Grading.pm index 860720c..ad2a825 100644 --- a/grading/lib/Pintos/Grading.pm +++ b/grading/lib/Pintos/Grading.pm @@ -96,9 +96,8 @@ EOF # Source tarballs. -# Extracts the group's source files into pintos/src, -# applies any patches providing in the grading directory, -# and installs a default pintos/src/constants.h +# Extracts the group's source files into pintos/src +# and applies any patches providing in the grading directory. sub extract_sources { # Make sure the output dir exists. -d ("output") || mkdir ("output") or die "output: mkdir: $!\n"; @@ -137,12 +136,6 @@ sub extract_sources { xsystem ("patch -fs -p0 < $patch", LOG => $stem, DIE => "applying patch $stem failed\n"); } - - # Install default pintos/src/constants.h. - open (CONSTANTS, ">pintos/src/constants.h") - or die "constants.h: create: $!\n"; - print CONSTANTS "#define THREAD_JOIN_IMPLEMENTED 1\n"; - close CONSTANTS; } # Returns the name of the tarball to extract. @@ -316,7 +309,13 @@ sub xsystem { 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); @@ -399,9 +398,15 @@ sub get_test_result { sub run_pintos { my ($cmd_line, %args) = @_; - 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 "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; } @@ -410,7 +415,14 @@ sub run_pintos { 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."; + } + return "preparation for test failed"; + } my (@output) = snarf ($outfile); # If there's a function "grade_$test", use it to evaluate the output.