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.
22 parse_cmd_line qw (pt-grow-stack pt-big-stk-obj pt-bad-addr pt-write-code
23 page-linear page-parallel page-merge-seq page-merge-par
24 page-shuffle mmap-read mmap-close mmap-unmap mmap-overlap
25 mmap-twice mmap-write mmap-exit mmap-shuffle);
27 # Default set of tests.
28 @TESTS = unless @TESTS > 0;
30 clean_dir (), exit if $action eq 'clean';
33 exit if $action eq 'extract';
36 exit if $action eq 'build';
38 run_and_grade_tests ();
41 exit if $action eq 'test';
43 assemble_final_grade ();
44 exit if $action eq 'assemble';
46 die "Don't know how to '$action'";
48 # Runs $test in directory output/$test.
49 # Returns 'ok' if it went ok, otherwise an explanation.
51 # Set up output directory.
52 xsystem ("cp $GRADES_DIR/$test.dsk output/$test/fs.dsk",
53 DIE => "cp failed\n");
54 xsystem ("pintos make-disk output/$test/swap.dsk 2 >/dev/null 2>&1",
55 DIE => "failed to create swap disk");
58 return run_pintos ("pintos "
59 . "--os-disk=pintos/src/vm/build/os.dsk "
60 . "--fs-disk=output/$test/fs.dsk "
61 . "--swap-disk=output/$test/swap.dsk "
62 . "-v run -q -ex \"$test\"",
67 sub grade_process_death {
68 my ($proc_name, @output) = @_;
70 verify_common (@output);
71 @output = get_core_output (@output);
72 die "First line of output is not `($proc_name) begin' message.\n"
73 if $output[0] ne "($proc_name) begin";
74 die "Output contains `FAIL' message.\n"
75 if grep (/FAIL/, @output);
76 die "Output contains spurious ($proc_name) message.\n"
77 if grep (/\($proc_name\)/, @output) > 1;
80 sub grade_pt_bad_addr {
81 grade_process_death ('pt-bad-addr', @_);
84 sub grade_pt_write_code {
85 grade_process_death ('pt-write-code', @_);
88 sub grade_mmap_unmap {
89 grade_process_death ('mmap-unmap', @_);