#! /usr/bin/perl # Find the directory that contains the grading files. use vars qw($GRADES_DIR); # Add our Perl library directory to the include path. BEGIN { ($GRADES_DIR = $0) =~ s#/[^/]+$##; -d $GRADES_DIR or die "$GRADES_DIR: stat: $!\n"; unshift @INC, "$GRADES_DIR/../lib"; } use warnings; use strict; use Pintos::Grading; our ($hw) = "filesys"; our ($verbose) = 0; # Verbosity of output our (@TESTS); # Tests to run. our ($clean) = 0; our ($grade) = 0; parse_cmd_line (); # Default set of tests. @TESTS = qw (sm-create sm-full sm-seq-block sm-seq-random sm-random lg-create lg-full lg-seq-block lg-seq-random lg-random grow-create grow-seq-sm grow-seq-lg grow-file-size grow-tell grow-sparse grow-too-big grow-root-sm grow-root-lg grow-dir-lg grow-two-files dir-mkdir dir-rmdir dir-mk-vine dir-rm-vine dir-mk-tree dir-rm-tree dir-lsdir dir-rm-cwd dir-rm-cwd-cd dir-rm-parent dir-rm-root dir-over-file dir-under-file dir-empty-name dir-open syn-remove syn-read syn-write syn-rw ) unless @TESTS > 0; compose_final_grade (), exit 0 if $grade; clean_dir (), exit 0 if $clean; # Create output directory, if it doesn't already exist. -d ("output") || mkdir ("output") or die "output: mkdir: $!\n"; # Extract submission. obtain_sources (); # Compile submission. compile (); # Verify that the proper directory was submitted. -d "pintos/src/threads" or die "pintos/src/threads: stat: $!\n"; # Run and grade the tests. run_and_grade_tests (); # Write output. write_grades (); write_details (); sub grade_dir_lsdir { my (@output) = @_; verify_common (@output); @output = get_core_output (@output); my ($begin); for my $i (0...$#output) { $begin = $i, last if $output[$i] eq '(dir-lsdir) begin'; } die "\"(dir-lsdir) begin\" does not appear in output\n" if !defined $begin; my ($end); for my $i (0...$#output) { $end = $i, last if $output[$i] eq '(dir-lsdir) end'; } die "\"(dir-lsdir) end\" does not appear in output\n" if !defined $end; die "\"begin\" follows \"end\" in output\n" if $begin > $end; my (%count); for my $fn (@output[$begin + 1...$end - 1]) { $fn =~ s/\s+$//; die "Unexpected file \"$fn\" in lsdir output\n" unless grep ($_ eq $fn, qw (. .. dir-lsdir)); die "File \"$fn\" listed twice in lsdir output\n" if $count{$fn}; $count{$fn}++; } die "No files in lsdir output\n" if scalar (keys (%count)) == 0; die "File \"dir-lsdir\" missing from lsdir output\n" if !$count{"dir-lsdir"}; } # This should be improved, but none of the fall 2004 submissions # survived the test! # I suppose it could be a bug in the test but a lot of the submissions # had kernel panics, etc. sub grade_syn_rw { verify_common (@_); }