3 # Find the directory that contains the grading files.
4 use vars qw($GRADES_DIR);
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";
17 our ($hw) = "filesys";
18 our ($verbose) = 0; # Verbosity of output
19 our (@TESTS); # Tests to run.
25 # Default set of tests.
26 @TESTS = qw (sm-create sm-full sm-seq-block sm-seq-random sm-random
28 lg-create lg-full lg-seq-block lg-seq-random lg-random
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
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
39 syn-remove syn-read syn-write syn-rw
42 compose_final_grade (), exit 0 if $grade;
43 clean_dir (), exit 0 if $clean;
45 # Create output directory, if it doesn't already exist.
46 -d ("output") || mkdir ("output") or die "output: mkdir: $!\n";
54 # Verify that the proper directory was submitted.
55 -d "pintos/src/threads" or die "pintos/src/threads: stat: $!\n";
57 # Run and grade the tests.
58 run_and_grade_tests ();
66 verify_common (@output);
67 @output = get_core_output (@output);
70 for my $i (0...$#output) {
71 $begin = $i, last if $output[$i] eq '(dir-lsdir) begin';
73 die "\"(dir-lsdir) begin\" does not appear in output\n" if !defined $begin;
76 for my $i (0...$#output) {
77 $end = $i, last if $output[$i] eq '(dir-lsdir) end';
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;
83 for my $fn (@output[$begin + 1...$end - 1]) {
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"
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"};
96 # This should be improved, but none of the fall 2004 submissions
98 # I suppose it could be a bug in the test but a lot of the submissions
99 # had kernel panics, etc.