blob: bf6fdca0d99a6d90a577f048b8d9c05d3ab6eced [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001#
2# Copyright OpenEmbedded Contributors
3#
Brad Bishop79641f22019-09-10 07:20:22 -04004# SPDX-License-Identifier: MIT
Patrick Williams92b42cb2022-09-03 06:53:57 -05005#
Brad Bishop79641f22019-09-10 07:20:22 -04006import os
Brad Bishop79641f22019-09-10 07:20:22 -04007from oeqa.core.decorator import OETestTag
Brad Bishopa34c0302019-09-23 22:34:48 -04008from oeqa.core.case import OEPTestResultTestCase
Brad Bishop79641f22019-09-10 07:20:22 -04009from oeqa.selftest.case import OESelftestTestCase
Patrick Williams45852732022-04-02 08:58:32 -050010from oeqa.utils.commands import bitbake, get_bb_vars
Brad Bishop79641f22019-09-10 07:20:22 -040011
12def parse_values(content):
13 for i in content:
14 for v in ["PASS", "FAIL", "XPASS", "XFAIL", "UNRESOLVED", "UNSUPPORTED", "UNTESTED", "ERROR", "WARNING"]:
15 if i.startswith(v + ": "):
16 yield i[len(v) + 2:].strip(), v
17 break
18
19@OETestTag("toolchain-user", "toolchain-system")
Brad Bishopa34c0302019-09-23 22:34:48 -040020class BinutilsCrossSelfTest(OESelftestTestCase, OEPTestResultTestCase):
Brad Bishop79641f22019-09-10 07:20:22 -040021 def test_binutils(self):
22 self.run_binutils("binutils")
23
24 def test_gas(self):
25 self.run_binutils("gas")
26
27 def test_ld(self):
28 self.run_binutils("ld")
29
30 def run_binutils(self, suite):
31 features = []
32 features.append('CHECK_TARGETS = "{0}"'.format(suite))
33 self.write_config("\n".join(features))
34
35 recipe = "binutils-cross-testsuite"
36 bb_vars = get_bb_vars(["B", "TARGET_SYS", "T"], recipe)
37 builddir, target_sys, tdir = bb_vars["B"], bb_vars["TARGET_SYS"], bb_vars["T"]
38
39 bitbake("{0} -c check".format(recipe))
40
Brad Bishop79641f22019-09-10 07:20:22 -040041 sumspath = os.path.join(builddir, suite, "{0}.sum".format(suite))
42 if not os.path.exists(sumspath):
43 sumspath = os.path.join(builddir, suite, "testsuite", "{0}.sum".format(suite))
Brad Bishopa34c0302019-09-23 22:34:48 -040044 logpath = os.path.splitext(sumspath)[0] + ".log"
Brad Bishop79641f22019-09-10 07:20:22 -040045
Brad Bishopa34c0302019-09-23 22:34:48 -040046 ptestsuite = "binutils-{}".format(suite) if suite != "binutils" else suite
47 self.ptest_section(ptestsuite, logfile = logpath)
Brad Bishop79641f22019-09-10 07:20:22 -040048 with open(sumspath, "r") as f:
49 for test, result in parse_values(f):
Brad Bishopa34c0302019-09-23 22:34:48 -040050 self.ptest_result(ptestsuite, test, result)
Brad Bishop79641f22019-09-10 07:20:22 -040051