• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright (C) 2016 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17class LinuxKselftestTestcase(object):
18    """Stores information needed to run the test case.
19
20    Attrubutes:
21        _testname: string, name of the testcase.
22        _testsuite: string, name of suite this testcase belongs to.
23        _test_cmd: string, shell command used to invoke this testcase.
24        _supported_arch: string list, architectures this testcase supports,
25            e.g. ["arm", "x86"].
26        _supported_bits: int list, bit version (32 or 64) of the testcase that
27            are currently supported, e.g. [32, 64].
28    """
29    def __init__(self, testsuite, test_cmd, supported_arch, supported_bits):
30        self._testsuite = testsuite
31        self._testname = "%s/%s" % (testsuite, test_cmd)
32        self._test_cmd = "./%s" % test_cmd
33        self._supported_arch = supported_arch
34        self._supported_bits = supported_bits
35
36    @property
37    def testname(self):
38        """Get test name."""
39        return self._testname
40
41    @property
42    def testsuite(self):
43        """Get test suite."""
44        return self._testsuite
45
46    @property
47    def test_cmd(self):
48        """Get test command."""
49        return self._test_cmd
50
51    @property
52    def supported_arch(self):
53        """Get list of architectures this test can run against."""
54        return self._supported_arch
55
56    @property
57    def supported_bits(self):
58        """Get list of versions (32 or 64 bit) of the test case that can run."""
59        return self._supported_bits
60
61    def IsRelevant(self, cpu_abi, n_bit):
62        """Checks whether this test case can run in n_bit against this cpu_abi.
63
64        Returns:
65            True if this testcase can run; False otherwise.
66        """
67        if cpu_abi is None or n_bit is None:
68            return False
69
70        if not n_bit in self._supported_bits:
71            return False
72
73        for arch in self._supported_arch:
74            if cpu_abi.find(arch) >= 0:
75                return True
76
77        return False
78
79