-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);
- }
- }
- }
-
- my ($details) = "";
- $details .= "$test actual output (line numbers added):\n";
- $details .= number_lines (1, \@actual);
- $details .= "\n$test expected output (line numbers added):\n";
- $details .= number_lines (1, \@expected);
- $details .= "\n$diff\n";
- $details{$test} = $details;
- die "Output differs from expected. Details at end of file.\n";
+sub check_mlfqs {
+ our (@mlfqs_off_stats);
+ our (@mlfqs_on_stats);
+ die "p1-4 didn't finish with MLFQS on or off\n"
+ if !defined (@mlfqs_off_stats) && !defined (@mlfqs_on_stats);
+ die "p1-4 didn't finish with MLFQS on\n"
+ if !defined (@mlfqs_on_stats);
+ die "p1-4 didn't finish with MLFQS off\n"
+ if !defined (@mlfqs_off_stats);