1##########################################################################
2# Copyright (c) 2009, 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 tests
12from common import TestCommon
13from results import PassFailResult
14
15MATCH_RE = "rx_caps 69 \[Frame cap[^\]]*\] \[x86_64 Page table at [^\]]*\]"
16
17class IdcTestCommon(TestCommon):
18    ''' Execute IDC test '''
19    name = "idc"
20
21    def get_finish_string(self):
22        return "client all done!"
23
24    def process_data(self, testdir, rawiter):
25        for line in rawiter:
26            if re.search(MATCH_RE, line):
27                return PassFailResult(True)
28        return PassFailResult(False)
29
30@tests.add_test
31class IdcTestLocal(IdcTestCommon):
32    ''' Execute IDC test. Client/server on same core'''
33    name = "idc_local"
34
35    def get_modules(self, build, machine):
36        modules = super(IdcTestLocal, self).get_modules(build, machine)
37        modules.add_module("idctest",
38                ["core=%d" % machine.get_coreids()[0], "server"])
39        modules.add_module("idctest",
40                ["core=%d" % machine.get_coreids()[0], "client"])
41        return modules
42
43@tests.add_test
44class IdcTestCross(IdcTestCommon):
45    ''' Execute IDC test. Client/server on different core'''
46    name = "idc_cross"
47
48    def get_modules(self, build, machine):
49        modules = super(IdcTestCross, self).get_modules(build, machine)
50        modules.add_module("idctest",
51                ["core=%d" % machine.get_coreids()[0], "server"])
52        modules.add_module("idctest",
53                ["core=%d" % machine.get_coreids()[1], "client"])
54        return modules
55