Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1 | # |
| 2 | # Copyright OpenEmbedded Contributors |
| 3 | # |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 4 | # SPDX-License-Identifier: MIT |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 5 | # |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 6 | import os |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame] | 7 | import time |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 8 | from oeqa.core.decorator import OETestTag |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 9 | from oeqa.core.case import OEPTestResultTestCase |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 10 | from oeqa.selftest.case import OESelftestTestCase |
Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 11 | from oeqa.utils.commands import bitbake, get_bb_vars |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 12 | |
| 13 | def parse_values(content): |
| 14 | for i in content: |
| 15 | for v in ["PASS", "FAIL", "XPASS", "XFAIL", "UNRESOLVED", "UNSUPPORTED", "UNTESTED", "ERROR", "WARNING"]: |
| 16 | if i.startswith(v + ": "): |
| 17 | yield i[len(v) + 2:].strip(), v |
| 18 | break |
| 19 | |
| 20 | @OETestTag("toolchain-user", "toolchain-system") |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 21 | class BinutilsCrossSelfTest(OESelftestTestCase, OEPTestResultTestCase): |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 22 | def test_binutils(self): |
| 23 | self.run_binutils("binutils") |
| 24 | |
| 25 | def test_gas(self): |
| 26 | self.run_binutils("gas") |
| 27 | |
| 28 | def test_ld(self): |
| 29 | self.run_binutils("ld") |
| 30 | |
| 31 | def run_binutils(self, suite): |
| 32 | features = [] |
| 33 | features.append('CHECK_TARGETS = "{0}"'.format(suite)) |
| 34 | self.write_config("\n".join(features)) |
| 35 | |
| 36 | recipe = "binutils-cross-testsuite" |
| 37 | bb_vars = get_bb_vars(["B", "TARGET_SYS", "T"], recipe) |
| 38 | builddir, target_sys, tdir = bb_vars["B"], bb_vars["TARGET_SYS"], bb_vars["T"] |
| 39 | |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame] | 40 | start_time = time.time() |
| 41 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 42 | bitbake("{0} -c check".format(recipe)) |
| 43 | |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame] | 44 | end_time = time.time() |
| 45 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 46 | sumspath = os.path.join(builddir, suite, "{0}.sum".format(suite)) |
| 47 | if not os.path.exists(sumspath): |
| 48 | sumspath = os.path.join(builddir, suite, "testsuite", "{0}.sum".format(suite)) |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 49 | logpath = os.path.splitext(sumspath)[0] + ".log" |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 50 | |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 51 | ptestsuite = "binutils-{}".format(suite) if suite != "binutils" else suite |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame] | 52 | self.ptest_section(ptestsuite, duration = int(end_time - start_time), logfile = logpath) |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 53 | with open(sumspath, "r") as f: |
| 54 | for test, result in parse_values(f): |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 55 | self.ptest_result(ptestsuite, test, result) |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 56 | |