blob: 821f52f5a886031b430ff6f988ed5813f269b817 [file] [log] [blame]
Brad Bishop79641f22019-09-10 07:20:22 -04001# SPDX-License-Identifier: MIT
2import os
3import sys
4import re
5import logging
6from oeqa.core.decorator import OETestTag
Brad Bishopa34c0302019-09-23 22:34:48 -04007from oeqa.core.case import OEPTestResultTestCase
Brad Bishop79641f22019-09-10 07:20:22 -04008from oeqa.selftest.case import OESelftestTestCase
9from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars
10
11def parse_values(content):
12 for i in content:
13 for v in ["PASS", "FAIL", "XPASS", "XFAIL", "UNRESOLVED", "UNSUPPORTED", "UNTESTED", "ERROR", "WARNING"]:
14 if i.startswith(v + ": "):
15 yield i[len(v) + 2:].strip(), v
16 break
17
18@OETestTag("toolchain-user", "toolchain-system")
Brad Bishopa34c0302019-09-23 22:34:48 -040019class BinutilsCrossSelfTest(OESelftestTestCase, OEPTestResultTestCase):
Brad Bishop79641f22019-09-10 07:20:22 -040020 def test_binutils(self):
21 self.run_binutils("binutils")
22
23 def test_gas(self):
24 self.run_binutils("gas")
25
26 def test_ld(self):
27 self.run_binutils("ld")
28
29 def run_binutils(self, suite):
30 features = []
31 features.append('CHECK_TARGETS = "{0}"'.format(suite))
32 self.write_config("\n".join(features))
33
34 recipe = "binutils-cross-testsuite"
35 bb_vars = get_bb_vars(["B", "TARGET_SYS", "T"], recipe)
36 builddir, target_sys, tdir = bb_vars["B"], bb_vars["TARGET_SYS"], bb_vars["T"]
37
38 bitbake("{0} -c check".format(recipe))
39
Brad Bishop79641f22019-09-10 07:20:22 -040040 sumspath = os.path.join(builddir, suite, "{0}.sum".format(suite))
41 if not os.path.exists(sumspath):
42 sumspath = os.path.join(builddir, suite, "testsuite", "{0}.sum".format(suite))
Brad Bishopa34c0302019-09-23 22:34:48 -040043 logpath = os.path.splitext(sumspath)[0] + ".log"
Brad Bishop79641f22019-09-10 07:20:22 -040044
Brad Bishopa34c0302019-09-23 22:34:48 -040045 ptestsuite = "binutils-{}".format(suite) if suite != "binutils" else suite
46 self.ptest_section(ptestsuite, logfile = logpath)
Brad Bishop79641f22019-09-10 07:20:22 -040047 with open(sumspath, "r") as f:
48 for test, result in parse_values(f):
Brad Bishopa34c0302019-09-23 22:34:48 -040049 self.ptest_result(ptestsuite, test, result)
Brad Bishop79641f22019-09-10 07:20:22 -040050