Fix syntax errors.
[pintos-anon] / grading / vm / run-tests
1 #! /usr/bin/perl
2
3 # Find the directory that contains the grading files.
4 our ($GRADES_DIR);
5
6 # Add our Perl library directory to the include path. 
7 BEGIN {
8     ($GRADES_DIR = $0) =~ s#/[^/]+$##;
9     -d $GRADES_DIR or die "$GRADES_DIR: stat: $!\n";
10     unshift @INC, "$GRADES_DIR/../lib";
11 }
12
13 use warnings;
14 use strict;
15 use Pintos::Grading;
16
17 our ($hw) = "vm";
18 our (@TESTS);           # Tests to run.
19 our ($test);
20 our ($action);
21
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);
26
27 clean_dir (), exit if $action eq 'clean';
28
29 extract_sources (); 
30 exit if $action eq 'extract';
31
32 build (); 
33 exit if $action eq 'build';
34
35 run_and_grade_tests (); 
36 write_grades (); 
37 write_details ();
38 exit if $action eq 'test';
39
40 assemble_final_grade ();
41 exit if $action eq 'assemble';
42
43 die "Don't know how to '$action'";
44
45 # Runs $test in directory output/$test.
46 # Returns 'ok' if it went ok, otherwise an explanation.
47 sub run_test {
48     # Set up output directory.
49     xsystem ("cp $GRADES_DIR/$test.dsk output/$test/fs.dsk",
50              DIE => "cp failed\n");
51     xsystem ("pintos make-disk output/$test/swap.dsk 2 >/dev/null 2>&1",
52              DIE => "failed to create swap disk");
53
54     # Run.
55     return run_pintos ("pintos "
56                        . "--os-disk=pintos/src/vm/build/os.dsk "
57                        . "--fs-disk=output/$test/fs.dsk "
58                        . "--swap-disk=output/$test/swap.dsk "
59                        . "-v run -q -ex \"$test\"",
60                        LOG => "$test/run",
61                        TIMEOUT => 600);
62 }
63 \f
64 sub grade_process_death {
65     my ($proc_name, @output) = @_;
66
67     verify_common (@output);
68     @output = get_core_output (@output);
69     die "First line of output is not `($proc_name) begin' message.\n"
70         if $output[0] ne "($proc_name) begin";
71     die "Output contains `FAIL' message.\n"
72         if grep (/FAIL/, @output);
73     die "Output contains spurious ($proc_name) message.\n"
74         if grep (/\($proc_name\)/, @output) > 1;
75 }
76
77 sub grade_pt_bad_addr {
78     grade_process_death ('pt-bad-addr', @_);
79 }
80
81 sub grade_pt_write_code {
82     grade_process_death ('pt-write-code', @_);
83 }
84
85 sub grade_mmap_unmap {
86     grade_process_death ('mmap-unmap', @_);
87 }