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