(strip_exit_codes) Include _ in the list of characters considered as
[pintos-anon] / grading / lib / Pintos / Grading.pm
index bf6099f74e9540eb8fe468ae2c44a099085b8ac2..90d9ba311ce548636748097f9a7f7a32c7d5b1ee 100644 (file)
@@ -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);
@@ -399,7 +405,8 @@ 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';
     if ($retval eq 'timeout') {
        my ($msg) = "Timed out after $args{TIMEOUT} seconds";
@@ -415,7 +422,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.
@@ -684,7 +698,7 @@ sub canonicalize_exit_codes {
 }
 
 sub strip_exit_codes {
-    return grep (!/^[-a-z0-9]+: exit\(-?\d+\)/, canonicalize_exit_codes (@_));
+    return grep (!/^[-_a-z0-9]+: exit\(-?\d+\)/, canonicalize_exit_codes (@_));
 }
 
 sub compare_output {