xref: /OK3568_Linux_fs/yocto/poky/meta/lib/oeqa/selftest/cases/binutils.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun# SPDX-License-Identifier: MIT
2*4882a593Smuzhiyunimport os
3*4882a593Smuzhiyunfrom oeqa.core.decorator import OETestTag
4*4882a593Smuzhiyunfrom oeqa.core.case import OEPTestResultTestCase
5*4882a593Smuzhiyunfrom oeqa.selftest.case import OESelftestTestCase
6*4882a593Smuzhiyunfrom oeqa.utils.commands import bitbake, get_bb_vars
7*4882a593Smuzhiyun
8*4882a593Smuzhiyundef parse_values(content):
9*4882a593Smuzhiyun    for i in content:
10*4882a593Smuzhiyun        for v in ["PASS", "FAIL", "XPASS", "XFAIL", "UNRESOLVED", "UNSUPPORTED", "UNTESTED", "ERROR", "WARNING"]:
11*4882a593Smuzhiyun            if i.startswith(v + ": "):
12*4882a593Smuzhiyun                yield i[len(v) + 2:].strip(), v
13*4882a593Smuzhiyun                break
14*4882a593Smuzhiyun
15*4882a593Smuzhiyun@OETestTag("toolchain-user", "toolchain-system")
16*4882a593Smuzhiyunclass BinutilsCrossSelfTest(OESelftestTestCase, OEPTestResultTestCase):
17*4882a593Smuzhiyun    def test_binutils(self):
18*4882a593Smuzhiyun        self.run_binutils("binutils")
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun    def test_gas(self):
21*4882a593Smuzhiyun        self.run_binutils("gas")
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun    def test_ld(self):
24*4882a593Smuzhiyun        self.run_binutils("ld")
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun    def run_binutils(self, suite):
27*4882a593Smuzhiyun        features = []
28*4882a593Smuzhiyun        features.append('CHECK_TARGETS = "{0}"'.format(suite))
29*4882a593Smuzhiyun        self.write_config("\n".join(features))
30*4882a593Smuzhiyun
31*4882a593Smuzhiyun        recipe = "binutils-cross-testsuite"
32*4882a593Smuzhiyun        bb_vars = get_bb_vars(["B", "TARGET_SYS", "T"], recipe)
33*4882a593Smuzhiyun        builddir, target_sys, tdir = bb_vars["B"], bb_vars["TARGET_SYS"], bb_vars["T"]
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun        bitbake("{0} -c check".format(recipe))
36*4882a593Smuzhiyun
37*4882a593Smuzhiyun        sumspath = os.path.join(builddir, suite, "{0}.sum".format(suite))
38*4882a593Smuzhiyun        if not os.path.exists(sumspath):
39*4882a593Smuzhiyun            sumspath = os.path.join(builddir, suite, "testsuite", "{0}.sum".format(suite))
40*4882a593Smuzhiyun        logpath = os.path.splitext(sumspath)[0] + ".log"
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun        ptestsuite = "binutils-{}".format(suite) if suite != "binutils" else suite
43*4882a593Smuzhiyun        self.ptest_section(ptestsuite, logfile = logpath)
44*4882a593Smuzhiyun        with open(sumspath, "r") as f:
45*4882a593Smuzhiyun            for test, result in parse_values(f):
46*4882a593Smuzhiyun                self.ptest_result(ptestsuite, test, result)
47*4882a593Smuzhiyun
48