Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: MIT |
| 2 | import os |
| 3 | import sys |
| 4 | import re |
| 5 | import logging |
| 6 | from oeqa.core.decorator import OETestTag |
| 7 | from oeqa.selftest.case import OESelftestTestCase |
| 8 | from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars |
| 9 | |
| 10 | def 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") |
| 18 | class 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 | |