Start factoring out common pieces of run-tests scripts.
[pintos-anon] / grading / userprog / run-tests
index dd7cd218b901d2e0fc889f4fe6916aa2e280f255..8104a7f307988b8d0ad193a8e597618b1f5b8d21 100755 (executable)
@@ -1,5 +1,15 @@
 #! /usr/bin/perl
 
+# Find the directory that contains the grading files.
+our ($GRADES_DIR);
+
+# Add our Perl library directory to the include path. 
+BEGIN {
+    ($GRADES_DIR = $0) =~ s#/[^/]+$##;
+    -d $GRADES_DIR or die "$GRADES_DIR: stat: $!\n";
+    unshift @INC, "$GRADES_DIR/../lib";
+}
+
 use warnings;
 use strict;
 use POSIX;
@@ -116,11 +126,6 @@ if ($grade) {
     exit 0;
 }
 
-# Find the directory that contains the grading files.
-our ($GRADES_DIR);
-($GRADES_DIR = $0) =~ s#/[^/]+$##;
--d $GRADES_DIR or die "$GRADES_DIR: stat: $!\n";
-
 if ($clean) {
     # Verify that we're roughly in the correct directory
     # before we go blasting away files.
@@ -489,11 +494,12 @@ sub fix_exit_codes {
        local ($_) = $output[$i];
        
        my ($process, $code);
-       if ((($process, $code) = /^([-a-zA-Z0-9 ]+):.*[ \(](-?\d+)\b\)?$/)
-           || (($process, $code) = /^([-a-zA-Z0-9 ]+) exit\((-?\d+)\)$/)
+       if ((($process, $code) = /^([-a-z0-9 ]+):.*[ \(](-?\d+)\b\)?$/)
+           || (($process, $code) = /^([-a-z0-9 ]+) exit\((-?\d+)\)$/)
            || (($process, $code)
-               = /^([-a-zA-Z0-9 ]+) \(.*\): exit\((-?\d+)\)$/)
-           || (($process, $code) = /^([-a-zA-Z0-9 ]+):\( (-?\d+) \) $/)
+               = /^([-a-z0-9 ]+) \(.*\): exit\((-?\d+)\)$/)
+           || (($process, $code) = /^([-a-z0-9 ]+):\( (-?\d+) \) $/)
+           || (($code, $process) = /^shell: exit\((-?\d+)\) \| ([-a-z0-9]+)/)
 ) {
            $process = substr ($process, 0, 15);
            $process =~ s/\s.*//;