-sub compare_output {
- my ($exp_file, @actual) = @_;
- my (@expected) = snarf ($exp_file);
-
- @actual = map ("$_\n", @actual);
- @expected = map ("$_\n", @expected);
-
- # Trim header and trailer from @actual.
- while (scalar (@actual) && $actual[0] ne $expected[0]) {
- shift (@actual);
- }
- die "First line of expected output was not present.\n" if !@actual;
- while (scalar (@actual) && $actual[$#actual] ne $expected[$#expected]) {
- pop (@actual);
- }
- die "Final line of expected output was not present.\n" if !@actual;
-
- # Check whether they're the same.
- if ($#actual == $#expected) {
- my ($eq) = 1;
- for (my ($i) = 0; $i <= $#expected; $i++) {
- $eq = 0 if $actual[$i] ne $expected[$i];
- }
- return if $eq;
- }
-
- # They differ. Output a diff.
- my ($diff) = "";
- my ($d) = Algorithm::Diff->new (\@expected, \@actual);
- $d->Base (1);
- while ($d->Next ()) {
- my ($ef, $el, $af, $al) = $d->Get (qw (min1 max1 min2 max2));
- if ($d->Same ()) {
- if ($af != $al) {
- $diff .= "Actual lines $af...$al match expected lines "
- . "$ef...$el.\n";
- } else {
- $diff .= "Actual line $af matches expected line $ef.\n";
- }
- } else {
- my (@i1) = $d->Items (1);
- my (@i2) = $d->Items (2);
- if (!@i1) {
- $diff .= "Extra or misplaced line(s) $af...$al "
- . "in actual output:\n";
- $diff .= number_lines ($af, \@i2);
- } elsif (!$d->Items (2)) {
- $diff .= "Expected line(s) $ef...$el missing or misplaced:\n";
- $diff .= number_lines ($ef, \@i1);
- } else {
- $diff .= "The following expected line(s) $ef...$el:\n";
- $diff .= number_lines ($ef, \@i1);
- $diff .= "became actual line(s) $af...$al:\n";
- $diff .= number_lines ($af, \@i2);
- }
+sub grade_mlfqs_priority {
+ our (@mlfqs_off_stats);
+ our (@mlfqs_on_stats);
+ eval {
+ check_mlfqs () if !defined (@mlfqs_on_stats);
+ for my $cat qw (CPU IO MIX) {
+ die "Priority changed away from PRI_DEFAULT (29) without MLFQS\n"
+ if $mlfqs_off_stats[0]{$cat}{MIN} != 29
+ || $mlfqs_off_stats[0]{$cat}{MAX} != 29;
+ die "Minimum priority never changed from PRI_DEFAULT (29) "
+ . "with MLFQS\n"
+ if $mlfqs_on_stats[0]{$cat}{MIN} == 29;
+ die "Maximum priority never changed from PRI_DEFAULT (29) "
+ . "with MLFQS\n"
+ if $mlfqs_on_stats[0]{$cat}{MAX} == 29;