7 my ($src_dir, $results_file, $grading_file) = @ARGV;
9 # Read pass/file verdicts from $results_file.
10 open (RESULTS, '<', $results_file) || die "$results_file: open: $!\n";
11 my (%verdicts, %verdict_counts);
13 my ($verdict, $test) = /^(pass|FAIL) (.*)$/ or die;
14 $verdicts{$test} = $verdict eq 'pass';
19 my (@overall, @rubrics, @summary);
20 my ($pct_actual, $pct_possible) = (0, 0);
24 open (GRADING, '<', $grading_file) || die "$grading_file: open: $!\n";
28 my ($max_pct, $rubric_suffix) = /^\s*(\d+(?:\.\d+)?)%\t(.*)/ or die;
29 my ($dir) = $rubric_suffix =~ /^(.*)\//;
30 my ($rubric_file) = "$src_dir/$rubric_suffix";
31 open (RUBRIC, '<', $rubric_file) or die "$rubric_file: open: $!\n";
33 # Rubric file must begin with title line.
36 $title =~ s/:$// or die;
37 $title .= " ($rubric_suffix):";
38 push (@rubrics, $title);
40 my ($score, $possible) = (0, 0);
41 my ($cnt, $passed) = (0, 0);
45 push (@rubrics, "\t$_"), next if /^-/;
46 push (@rubrics, ""), next if /^\s*$/;
47 my ($poss, $name) = /^(\d+)\t(.*)$/ or die;
48 my ($test) = "$dir/$name";
50 if (!defined $verdicts{$test}) {
51 push (@overall, "warning: $test not tested, assuming failure");
52 } elsif ($verdicts{$test}) {
56 push (@failures, $test) if !$points;
57 $verdict_counts{$test}++;
58 push (@rubrics, sprintf ("\t%4s%2d/%2d %s",
59 $points ? '' : '**', $points, $poss, $test));
67 push (@rubrics, "\t- Section summary.");
68 push (@rubrics, sprintf ("\t%4s%3d/%3d %s",
69 '', $passed, $cnt, 'tests passed'));
70 push (@rubrics, sprintf ("\t%4s%3d/%3d %s",
71 '', $score, $possible, 'points subtotal'));
74 my ($pct) = ($score / $possible) * $max_pct;
75 push (@summary, sprintf ("%-45s %3d/%3d %5.1f%%/%5.1f%%",
80 $pct_possible += $max_pct;
85 = "--------------------------------------------- --- --- ------ ------";
87 "SUMMARY BY TEST SET",
89 sprintf ("%-45s %3s %3s %6s %6s",
90 "Test Set", "Pts", "Max", "% Ttl", "% Max"),
94 sprintf ("%-45s %3s %3s %5.1f%%/%5.1f%%",
95 'Total', '', '', $pct_actual, $pct_possible));
98 "SUMMARY OF INDIVIDUAL TESTS",
101 foreach my $name (keys (%verdicts)) {
102 my ($count) = $verdict_counts{$name};
103 if (!defined ($count) || $count != 1) {
104 if (!defined ($count) || !$count) {
105 push (@overall, "warning: test $name doesn't count for grading");
108 "warning: test $name counted $count times in grading");
112 push (@overall, sprintf ("TOTAL TESTING SCORE: %.1f%%", $pct_actual));
113 if (sprintf ("%.1f", $pct_actual) eq sprintf ("%.1f", $pct_possible)) {
114 push (@overall, "ALL TESTED PASSED -- PERFECT SCORE");
117 my (@divider) = ('', '- ' x 38, '');
119 print map ("$_\n", @overall, @divider, @summary, @divider, @rubrics);
121 for my $test (@failures) {
122 print map ("$_\n", @divider);
123 print "DETAILS OF $test FAILURE:\n\n";
125 if (open (RESULT, '<', "$test.result")) {
126 my $first_line = <RESULT>;
135 if (open (OUTPUT, '<', "$test.output")) {
136 print "\nOUTPUT FROM $test:\n\n";
138 my ($panics, $boots) = (0, 0);
140 if (/PANIC/ && ++$panics > 2) {
141 print "[...details of additional panic(s) omitted...]\n";
145 if (/Pintos booting/ && ++$boots > 1) {
146 print "[...details of reboot(s) omitted...]\n";