3 # Find the directory that contains the grading files.
6 # Add our Perl library directory to the include path.
8 ($GRADES_DIR = $0) =~ s#/[^/]+$##;
9 -d $GRADES_DIR or die "$GRADES_DIR: stat: $!\n";
10 unshift @INC, "$GRADES_DIR/../lib";
18 our (@TESTS); # Tests to run.
24 # Default set of tests.
25 @TESTS = qw (pt-grow-stack pt-big-stk-obj pt-bad-addr pt-write-code
26 page-linear page-parallel page-merge-seq page-merge-par
27 page-shuffle mmap-read mmap-close mmap-unmap mmap-overlap
28 mmap-twice mmap-write mmap-exit mmap-shuffle
31 clean_dir (), exit if $action eq 'clean';
34 exit if $action eq 'extract';
37 exit if $action eq 'build';
39 run_and_grade_tests ();
42 exit if $action eq 'test';
44 assemble_final_grade ();
45 exit if $action eq 'assemble';
47 die "Don't know how to '$action'";
49 # Runs $test in directory output/$test.
50 # Returns 'ok' if it went ok, otherwise an explanation.
52 # Set up output directory.
53 xsystem ("cp $GRADES_DIR/$test.dsk output/$test/fs.dsk",
54 DIE => "cp failed\n");
55 xsystem ("pintos make-disk output/$test/swap.dsk 2 >/dev/null 2>&1",
56 DIE => "failed to create swap disk");
59 return run_pintos ("pintos "
60 . "--os-disk=pintos/src/vm/build/os.dsk "
61 . "--fs-disk=output/$test/fs.dsk "
62 . "--swap-disk=output/$test/swap.dsk "
63 . "-v run -q -ex \"$test\"",
68 sub grade_process_death {
69 my ($proc_name, @output) = @_;
71 verify_common (@output);
72 @output = get_core_output (@output);
73 die "First line of output is not `($proc_name) begin' message.\n"
74 if $output[0] ne "($proc_name) begin";
75 die "Output contains `FAIL' message.\n"
76 if grep (/FAIL/, @output);
77 die "Output contains spurious ($proc_name) message.\n"
78 if grep (/\($proc_name\)/, @output) > 1;
81 sub grade_pt_bad_addr {
82 grade_process_death ('pt-bad-addr', @_);
85 sub grade_pt_write_code {
86 grade_process_death ('pt-write-code', @_);
89 sub grade_mmap_unmap {
90 grade_process_death ('mmap-unmap', @_);