1##########################################################################
2# Copyright (c) 2009, 2010, ETH Zurich.
3# All rights reserved.
4#
5# This file is distributed under the terms in the attached LICENSE file.
6# If you do not find this file, copies can be found by writing to:
7# ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
8##########################################################################
9
10import re
11import debug, tests, datetime
12from common import TestCommon, TimeoutError
13from results import RowResults
14
15# timeout for a complete run, including setup etc.
16CLOCKDRIFT_TIMEOUT = datetime.timedelta(hours=13)
17
18@tests.add_test
19class ClockDriftTest(TestCommon):
20    ''' APIC clock drift test '''
21    name = "clockdrift_apic"
22
23    def get_modules(self, build, machine):
24        modules = super(ClockDriftTest, self).get_modules(build, machine)
25        modules.add_module("apicdrift_bench", [machine.get_ncores()])
26        return modules
27
28    def get_finish_string(self):
29        return "client done."
30
31    def boot(self, *args):
32        super(ClockDriftTest, self).boot(*args)
33        self.set_timeout(CLOCKDRIFT_TIMEOUT)
34
35    def process_data(self, testdir, rawiter):
36        corestr = None
37        lastdata = None
38
39        for line in rawiter:
40            m = re.match("Running on (\d+) cores.", line)
41            if m:
42                ncores = int(m.group(1))
43                results = RowResults(["core %d to %d" % (n, (n + 1) % ncores) for n in range(ncores)])
44                corestr = "\d+: "
45                for n in range(ncores):
46                    corestr += "(\d+) "
47                continue
48
49            if corestr != None:
50                m = re.match(corestr, line)
51                if m:
52                    data = [int(m.group(n)) for n in range(1, ncores + 1)]
53                    if lastdata != None:
54                        diffs = [data[0] - lastdata]
55                    else:
56                        diffs = [0]
57                    diffs += [(data[n] - data[n - 1]) for n in range(1, ncores)]
58                    results.add_row(diffs)
59                    lastdata = data[ncores - 1]
60
61        return results
62