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