blob: 9bc752040f871b02278a9e5a0decc7baf6dc8487 [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
7from oeqa.selftest.case import OESelftestTestCase
8from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars
9
10def parse_values(content):
11 for i in content:
12 for v in ["PASS", "FAIL", "XPASS", "XFAIL", "UNRESOLVED", "UNSUPPORTED", "UNTESTED", "ERROR", "WARNING"]:
13 if i.startswith(v + ": "):
14 yield i[len(v) + 2:].strip(), v
15 break
16
17@OETestTag("toolchain-user", "toolchain-system")
18class BinutilsCrossSelfTest(OESelftestTestCase):
19 def test_binutils(self):
20 self.run_binutils("binutils")
21
22 def test_gas(self):
23 self.run_binutils("gas")
24
25 def test_ld(self):
26 self.run_binutils("ld")
27
28 def run_binutils(self, suite):
29 features = []
30 features.append('CHECK_TARGETS = "{0}"'.format(suite))
31 self.write_config("\n".join(features))
32
33 recipe = "binutils-cross-testsuite"
34 bb_vars = get_bb_vars(["B", "TARGET_SYS", "T"], recipe)
35 builddir, target_sys, tdir = bb_vars["B"], bb_vars["TARGET_SYS"], bb_vars["T"]
36
37 bitbake("{0} -c check".format(recipe))
38
39 ptestsuite = "binutils-{}".format(suite) if suite != "binutils" else suite
40 self.extraresults = {"ptestresult.sections" : {ptestsuite : {}}}
41
42 sumspath = os.path.join(builddir, suite, "{0}.sum".format(suite))
43 if not os.path.exists(sumspath):
44 sumspath = os.path.join(builddir, suite, "testsuite", "{0}.sum".format(suite))
45
46 with open(sumspath, "r") as f:
47 for test, result in parse_values(f):
48 self.extraresults["ptestresult.{}.{}".format(ptestsuite, test)] = {"status" : result}
49