Finish up filesys grading stuff.
[pintos-anon] / grading / filesys / run-tests
1 #! /usr/bin/perl
2
3 # Find the directory that contains the grading files.
4 use vars qw($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) = "filesys";
18 our ($verbose) = 0;     # Verbosity of output
19 our (@TESTS);           # Tests to run.
20 our ($clean) = 0;
21 our ($grade) = 0;
22
23 parse_cmd_line ();
24
25 # Default set of tests.
26 @TESTS = qw (sm-create sm-full sm-seq-block sm-seq-random sm-random
27
28              lg-create lg-full lg-seq-block lg-seq-random lg-random
29
30              grow-create grow-seq-sm grow-seq-lg grow-file-size grow-tell
31              grow-sparse grow-too-big grow-root-sm grow-root-lg grow-dir-lg 
32              grow-two-files
33
34              dir-mkdir dir-rmdir dir-mk-vine dir-rm-vine dir-mk-tree
35              dir-rm-tree dir-lsdir dir-rm-cwd dir-rm-cwd-cd
36              dir-rm-parent dir-rm-root dir-over-file dir-under-file
37              dir-empty-name dir-open
38
39              syn-remove syn-read syn-write syn-rw
40              ) unless @TESTS > 0;
41
42 compose_final_grade (), exit 0 if $grade;
43 clean_dir (), exit 0 if $clean;
44
45 # Create output directory, if it doesn't already exist.
46 -d ("output") || mkdir ("output") or die "output: mkdir: $!\n";
47
48 # Extract submission.
49 obtain_sources ();
50
51 # Compile submission.
52 compile ();
53
54 # Verify that the proper directory was submitted.
55 -d "pintos/src/threads" or die "pintos/src/threads: stat: $!\n";
56
57 # Run and grade the tests.
58 run_and_grade_tests ();
59
60 # Write output.
61 write_grades ();
62 write_details ();
63
64 sub grade_dir_lsdir {
65     my (@output) = @_;
66     verify_common (@output);
67     @output = get_core_output (@output);
68
69     my ($begin);
70     for my $i (0...$#output) {
71         $begin = $i, last if $output[$i] eq '(dir-lsdir) begin';
72     }
73     die "\"(dir-lsdir) begin\" does not appear in output\n" if !defined $begin;
74
75     my ($end);
76     for my $i (0...$#output) {
77         $end = $i, last if $output[$i] eq '(dir-lsdir) end';
78     }
79     die "\"(dir-lsdir) end\" does not appear in output\n" if !defined $end;
80     die "\"begin\" follows \"end\" in output\n" if $begin > $end;
81
82     my (%count);
83     for my $fn (@output[$begin + 1...$end - 1]) {
84         $fn =~ s/\s+$//;
85         die "Unexpected file \"$fn\" in lsdir output\n"
86             unless grep ($_ eq $fn, qw (. .. dir-lsdir));
87         die "File \"$fn\" listed twice in lsdir output\n"
88             if $count{$fn};
89         $count{$fn}++;
90     }
91     die "No files in lsdir output\n" if scalar (keys (%count)) == 0;
92     die "File \"dir-lsdir\" missing from lsdir output\n"
93         if !$count{"dir-lsdir"};
94 }
95
96 # This should be improved, but none of the fall 2004 submissions
97 # survived the test!
98 # I suppose it could be a bug in the test but a lot of the submissions
99 # had kernel panics, etc.
100 sub grade_syn_rw {
101     verify_common (@_);
102 }