aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/threads/mlfqs-load-60.ck
blob: cb69220024ef7973a3218623a372f2e1ab3477e9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -*- perl -*-
use strict;
use warnings;
use tests::tests;
use tests::threads::mlfqs;

our ($test);

my (@output) = read_text_file ("$test.output");
common_checks ("run", @output);
@output = get_core_output ("run", @output);

# Get actual values.
local ($_);
my (@actual);
foreach (@output) {
    my ($t, $load_avg) = /After (\d+) seconds, load average=(\d+\.\d+)\./
      or next;
    $actual[$t] = $load_avg;
}

# Calculate expected values.
my ($load_avg) = 0;
my ($recent) = 0;
my (@expected);
for (my ($t) = 0; $t < 180; $t++) {
    my ($ready) = $t < 60 ? 60 : 0;
    $load_avg = (59/60) * $load_avg + (1/60) * $ready;
    $expected[$t] = $load_avg;
}

mlfqs_compare ("time", "%.2f", \@actual, \@expected, 3.5, [2, 178, 2],
	       "Some load average values were missing or "
	       . "differed from those expected "
	       . "by more than 3.5.");
pass;