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