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