blob: 3b0b44b3908d532de313e6bb3f44766733a0e010 [file] [log] [blame]
Brad Bishop79641f22019-09-10 07:20:22 -04001# SPDX-License-Identifier: MIT
2import os
Brad Bishop79641f22019-09-10 07:20:22 -04003from oeqa.core.decorator import OETestTag
Brad Bishopa34c0302019-09-23 22:34:48 -04004from oeqa.core.case import OEPTestResultTestCase
Brad Bishop79641f22019-09-10 07:20:22 -04005from oeqa.selftest.case import OESelftestTestCase
Patrick Williams45852732022-04-02 08:58:32 -05006from oeqa.utils.commands import bitbake, get_bb_vars
Brad Bishop79641f22019-09-10 07:20:22 -04007
8def parse_values(content):
9 for i in content:
10 for v in ["PASS", "FAIL", "XPASS", "XFAIL", "UNRESOLVED", "UNSUPPORTED", "UNTESTED", "ERROR", "WARNING"]:
11 if i.startswith(v + ": "):
12 yield i[len(v) + 2:].strip(), v
13 break
14
15@OETestTag("toolchain-user", "toolchain-system")
Brad Bishopa34c0302019-09-23 22:34:48 -040016class BinutilsCrossSelfTest(OESelftestTestCase, OEPTestResultTestCase):
Brad Bishop79641f22019-09-10 07:20:22 -040017 def test_binutils(self):
18 self.run_binutils("binutils")
19
20 def test_gas(self):
21 self.run_binutils("gas")
22
23 def test_ld(self):
24 self.run_binutils("ld")
25
26 def run_binutils(self, suite):
27 features = []
28 features.append('CHECK_TARGETS = "{0}"'.format(suite))
29 self.write_config("\n".join(features))
30
31 recipe = "binutils-cross-testsuite"
32 bb_vars = get_bb_vars(["B", "TARGET_SYS", "T"], recipe)
33 builddir, target_sys, tdir = bb_vars["B"], bb_vars["TARGET_SYS"], bb_vars["T"]
34
35 bitbake("{0} -c check".format(recipe))
36
Brad Bishop79641f22019-09-10 07:20:22 -040037 sumspath = os.path.join(builddir, suite, "{0}.sum".format(suite))
38 if not os.path.exists(sumspath):
39 sumspath = os.path.join(builddir, suite, "testsuite", "{0}.sum".format(suite))
Brad Bishopa34c0302019-09-23 22:34:48 -040040 logpath = os.path.splitext(sumspath)[0] + ".log"
Brad Bishop79641f22019-09-10 07:20:22 -040041
Brad Bishopa34c0302019-09-23 22:34:48 -040042 ptestsuite = "binutils-{}".format(suite) if suite != "binutils" else suite
43 self.ptest_section(ptestsuite, logfile = logpath)
Brad Bishop79641f22019-09-10 07:20:22 -040044 with open(sumspath, "r") as f:
45 for test, result in parse_values(f):
Brad Bishopa34c0302019-09-23 22:34:48 -040046 self.ptest_result(ptestsuite, test, result)
Brad Bishop79641f22019-09-10 07:20:22 -040047