Make tests public. Rewrite most tests. Add tests.
[pintos-anon] / src / tests / threads / mlfqs-load-60.ck
1 # -*- perl -*-
2 use strict;
3 use warnings;
4 use tests::tests;
5 use tests::threads::mlfqs;
6
7 our ($test);
8
9 my (@output) = read_text_file ("$test.output");
10 common_checks (@output);
11 @output = get_core_output (@output);
12
13 # Get actual values.
14 local ($_);
15 my (@actual);
16 foreach (@output) {
17     my ($t, $load_avg) = /After (\d+) seconds, load average=(\d+\.\d+)\./
18       or next;
19     $actual[$t] = $load_avg;
20 }
21
22 # Calculate expected values.
23 my ($load_avg) = 0;
24 my ($recent) = 0;
25 my (@expected);
26 for (my ($t) = 0; $t < 180; $t++) {
27     my ($ready) = $t < 60 ? 60 : 0;
28     $load_avg = (59/60) * $load_avg + (1/60) * $ready;
29     $expected[$t] = $load_avg;
30 }
31
32 mlfqs_compare ("time", "%.2f", \@actual, \@expected, 2.5, [2, 178, 2],
33                "Some load average values were missing or "
34                . "differed from those expected "
35                . "by more than 2.5.");
36 pass;