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_var, get_bb_vars, runqemu |
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 | |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 20 | class GccSelfTestBase(OESelftestTestCase, OEPTestResultTestCase): |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 21 | def check_skip(self, suite): |
| 22 | targets = get_bb_var("RUNTIMETARGET", "gcc-runtime").split() |
| 23 | if suite not in targets: |
| 24 | self.skipTest("Target does not use {0}".format(suite)) |
| 25 | |
| 26 | def run_check(self, *suites, ssh = None): |
| 27 | targets = set() |
| 28 | for s in suites: |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 29 | if s == "gcc": |
| 30 | targets.add("check-gcc-c") |
| 31 | elif s == "g++": |
| 32 | targets.add("check-gcc-c++") |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 33 | else: |
| 34 | targets.add("check-target-{}".format(s)) |
| 35 | |
| 36 | # configure ssh target |
| 37 | features = [] |
| 38 | features.append('MAKE_CHECK_TARGETS = "{0}"'.format(" ".join(targets))) |
| 39 | if ssh is not None: |
| 40 | features.append('TOOLCHAIN_TEST_TARGET = "ssh"') |
| 41 | features.append('TOOLCHAIN_TEST_HOST = "{0}"'.format(ssh)) |
| 42 | features.append('TOOLCHAIN_TEST_HOST_USER = "root"') |
| 43 | features.append('TOOLCHAIN_TEST_HOST_PORT = "22"') |
| 44 | self.write_config("\n".join(features)) |
| 45 | |
| 46 | recipe = "gcc-runtime" |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame] | 47 | |
| 48 | start_time = time.time() |
| 49 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 50 | bitbake("{} -c check".format(recipe)) |
| 51 | |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame] | 52 | end_time = time.time() |
| 53 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 54 | bb_vars = get_bb_vars(["B", "TARGET_SYS"], recipe) |
| 55 | builddir, target_sys = bb_vars["B"], bb_vars["TARGET_SYS"] |
| 56 | |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 57 | for suite in suites: |
| 58 | sumspath = os.path.join(builddir, "gcc", "testsuite", suite, "{0}.sum".format(suite)) |
| 59 | if not os.path.exists(sumspath): # check in target dirs |
| 60 | sumspath = os.path.join(builddir, target_sys, suite, "testsuite", "{0}.sum".format(suite)) |
| 61 | if not os.path.exists(sumspath): # handle libstdc++-v3 -> libstdc++ |
| 62 | sumspath = os.path.join(builddir, target_sys, suite, "testsuite", "{0}.sum".format(suite.split("-")[0])) |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 63 | logpath = os.path.splitext(sumspath)[0] + ".log" |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 64 | |
| 65 | ptestsuite = "gcc-{}".format(suite) if suite != "gcc" else suite |
| 66 | ptestsuite = ptestsuite + "-user" if ssh is None else ptestsuite |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame] | 67 | self.ptest_section(ptestsuite, duration = int(end_time - start_time), logfile = logpath) |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 68 | with open(sumspath, "r") as f: |
| 69 | for test, result in parse_values(f): |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 70 | self.ptest_result(ptestsuite, test, result) |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 71 | |
| 72 | def run_check_emulated(self, *args, **kwargs): |
| 73 | # build core-image-minimal with required packages |
| 74 | default_installed_packages = ["libgcc", "libstdc++", "libatomic", "libgomp"] |
| 75 | features = [] |
| 76 | features.append('IMAGE_FEATURES += "ssh-server-openssh"') |
| 77 | features.append('CORE_IMAGE_EXTRA_INSTALL += "{0}"'.format(" ".join(default_installed_packages))) |
| 78 | self.write_config("\n".join(features)) |
| 79 | bitbake("core-image-minimal") |
| 80 | |
| 81 | # wrap the execution with a qemu instance |
| 82 | with runqemu("core-image-minimal", runqemuparams = "nographic") as qemu: |
| 83 | # validate that SSH is working |
| 84 | status, _ = qemu.run("uname") |
| 85 | self.assertEqual(status, 0) |
| 86 | |
| 87 | return self.run_check(*args, ssh=qemu.ip, **kwargs) |
| 88 | |
| 89 | @OETestTag("toolchain-user") |
| 90 | class GccCrossSelfTest(GccSelfTestBase): |
| 91 | def test_cross_gcc(self): |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 92 | self.run_check("gcc") |
| 93 | |
| 94 | @OETestTag("toolchain-user") |
| 95 | class GxxCrossSelfTest(GccSelfTestBase): |
| 96 | def test_cross_gxx(self): |
| 97 | self.run_check("g++") |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 98 | |
| 99 | @OETestTag("toolchain-user") |
| 100 | class GccLibAtomicSelfTest(GccSelfTestBase): |
| 101 | def test_libatomic(self): |
| 102 | self.run_check("libatomic") |
| 103 | |
| 104 | @OETestTag("toolchain-user") |
| 105 | class GccLibGompSelfTest(GccSelfTestBase): |
| 106 | def test_libgomp(self): |
| 107 | self.run_check("libgomp") |
| 108 | |
| 109 | @OETestTag("toolchain-user") |
| 110 | class GccLibStdCxxSelfTest(GccSelfTestBase): |
| 111 | def test_libstdcxx(self): |
| 112 | self.run_check("libstdc++-v3") |
| 113 | |
| 114 | @OETestTag("toolchain-user") |
| 115 | class GccLibSspSelfTest(GccSelfTestBase): |
| 116 | def test_libssp(self): |
| 117 | self.check_skip("libssp") |
| 118 | self.run_check("libssp") |
| 119 | |
| 120 | @OETestTag("toolchain-user") |
| 121 | class GccLibItmSelfTest(GccSelfTestBase): |
| 122 | def test_libitm(self): |
| 123 | self.check_skip("libitm") |
| 124 | self.run_check("libitm") |
| 125 | |
| 126 | @OETestTag("toolchain-system") |
Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 127 | @OETestTag("runqemu") |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 128 | class GccCrossSelfTestSystemEmulated(GccSelfTestBase): |
| 129 | def test_cross_gcc(self): |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 130 | self.run_check_emulated("gcc") |
| 131 | |
| 132 | @OETestTag("toolchain-system") |
Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 133 | @OETestTag("runqemu") |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 134 | class GxxCrossSelfTestSystemEmulated(GccSelfTestBase): |
| 135 | def test_cross_gxx(self): |
| 136 | self.run_check_emulated("g++") |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 137 | |
| 138 | @OETestTag("toolchain-system") |
Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 139 | @OETestTag("runqemu") |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 140 | class GccLibAtomicSelfTestSystemEmulated(GccSelfTestBase): |
| 141 | def test_libatomic(self): |
| 142 | self.run_check_emulated("libatomic") |
| 143 | |
| 144 | @OETestTag("toolchain-system") |
Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 145 | @OETestTag("runqemu") |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 146 | class GccLibGompSelfTestSystemEmulated(GccSelfTestBase): |
| 147 | def test_libgomp(self): |
| 148 | self.run_check_emulated("libgomp") |
| 149 | |
| 150 | @OETestTag("toolchain-system") |
Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 151 | @OETestTag("runqemu") |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 152 | class GccLibStdCxxSelfTestSystemEmulated(GccSelfTestBase): |
| 153 | def test_libstdcxx(self): |
| 154 | self.run_check_emulated("libstdc++-v3") |
| 155 | |
| 156 | @OETestTag("toolchain-system") |
Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 157 | @OETestTag("runqemu") |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 158 | class GccLibSspSelfTestSystemEmulated(GccSelfTestBase): |
| 159 | def test_libssp(self): |
| 160 | self.check_skip("libssp") |
| 161 | self.run_check_emulated("libssp") |
| 162 | |
| 163 | @OETestTag("toolchain-system") |
Patrick Williams | 4585273 | 2022-04-02 08:58:32 -0500 | [diff] [blame] | 164 | @OETestTag("runqemu") |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 165 | class GccLibItmSelfTestSystemEmulated(GccSelfTestBase): |
| 166 | def test_libitm(self): |
| 167 | self.check_skip("libitm") |
| 168 | self.run_check_emulated("libitm") |
| 169 | |