X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=grading%2Flib%2FPintos%2FGrading.pm;h=30ac7101493b473bf96a316f0268e986f64581fb;hb=2969f4df6a95b37e05ad6aa562ae82206b646eb0;hp=7e5ec67fb008f7fc5ad06353b1f2c9ae574eb98f;hpb=415941c1e0a6fc5ce263d8355fde980239c0f844;p=pintos-anon diff --git a/grading/lib/Pintos/Grading.pm b/grading/lib/Pintos/Grading.pm index 7e5ec67..30ac710 100644 --- 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"); } - 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); @@ -345,12 +351,9 @@ sub xsystem { 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)) { @@ -402,10 +405,15 @@ sub get_test_result { 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 "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; }