our $hw;
use POSIX;
-use Getopt::Long;
+use Getopt::Long qw(:config no_ignore_case);
use Algorithm::Diff;
\f
+# We execute lots of subprocesses.
+# Without this, our stdout output can get flushed multiple times,
+# which is harmless but looks bizarre.
+$| = 1;
+
sub parse_cmd_line {
+ my ($do_regex, $no_regex);
GetOptions ("v|verbose+" => \$verbose,
"h|help" => sub { usage (0) },
- "T|tests=s" => \@TESTS,
+ "d|do-tests=s" => \$do_regex,
+ "n|no-tests=s" => \$no_regex,
"c|clean" => sub { set_action ('clean'); },
"x|extract" => sub { set_action ('extract'); },
"b|build" => sub { set_action ('build'); },
"t|test" => sub { set_action ('test'); },
"a|assemble" => sub { set_action ('assemble'); })
or die "Malformed command line; use --help for help.\n";
- die "Non-option argument not supported; use --help for help.\n"
+ die "Non-option arguments not supported; use --help for help.\n"
if @ARGV > 0;
@TESTS = split(/,/, join (',', @TESTS)) if defined @TESTS;
if (!defined $action) {
$action = -e 'review.txt' ? 'assemble' : 'test';
}
+
+ my (@default_tests) = @_;
+ @TESTS = @default_tests;
+ @TESTS = grep (/$do_regex/, @TESTS) if defined $do_regex;
+ @TESTS = grep (!/$no_regex/, @TESTS) if defined $no_regex;
}
sub set_action {
Options:
-c, --clean Delete test results and temporary files, then exit.
- -T, --tests=TESTS Run only the specified comma-separated tests.
+ -d, --do-tests=RE Run only tests that match the given regular expression.
+ -n, --no-tests=RE Do not run tests that match the given regular expression.
-x, --extract Stop after step 1.
-b, --build Stop after step 2.
-t, --test Stop after step 3 (default if "review.txt" not present).
# applies any patches providing in the grading directory,
# and installs a default pintos/src/constants.h
sub extract_sources {
- # Nothing to do if we already have a source tree.
- return if -d "pintos";
-
+ # Make sure the output dir exists.
-d ("output") || mkdir ("output") or die "output: mkdir: $!\n";
+ # Nothing else to do if we already have a source tree.
+ return if -d "pintos";
+
my ($tarball) = choose_tarball ();
# Extract sources.
if $grade eq 'ok' && defined $details{$test};
print "$msg\n";
- $result{$test} = $result;
+ $result{$test} = $grade;
}
}
# Grade the test.
sub grade_test {
# Read test output.
- my (@output) = snarf ("output/$test/run.out");
+ my ($outfile) = "output/$test/run.out";
+ die "$outfile: missing test output file (make failed?)" if ! -e $outfile;
+ my (@output) = snarf ($outfile);
# If there's a function "grade_$test", use it to evaluate the output.
# If there's a file "$GRADES_DIR/$test.exp", compare its contents
}
my ($kernel_o);
if ($hw eq 'threads') {
- $kernel_o = "pintos/src/filesys/build/kernel.o";
+ $kernel_o = "output/$test/kernel.o";
} else {
$kernel_o = "pintos/src/$hw/build/kernel.o";
}