blob: b9ea03ae62d5419f599134b3e0506a0d6841cfcf [file] [log] [blame]
Brad Bishop79641f22019-09-10 07:20:22 -04001# SPDX-License-Identifier: MIT
2import os
3from oeqa.core.decorator import OETestTag
Brad Bishopa34c0302019-09-23 22:34:48 -04004from oeqa.core.case import OEPTestResultTestCase
Brad Bishop79641f22019-09-10 07:20:22 -04005from oeqa.selftest.case import OESelftestTestCase
Patrick Williams45852732022-04-02 08:58:32 -05006from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars, runqemu
Brad Bishop79641f22019-09-10 07:20:22 -04007
8def 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 Bishopa34c0302019-09-23 22:34:48 -040015class GccSelfTestBase(OESelftestTestCase, OEPTestResultTestCase):
Brad Bishop79641f22019-09-10 07:20:22 -040016 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 Geissler82c905d2020-04-13 13:39:40 -050024 if s == "gcc":
25 targets.add("check-gcc-c")
26 elif s == "g++":
27 targets.add("check-gcc-c++")
Brad Bishop79641f22019-09-10 07:20:22 -040028 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 Bishop79641f22019-09-10 07:20:22 -040047 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 Bishopa34c0302019-09-23 22:34:48 -040053 logpath = os.path.splitext(sumspath)[0] + ".log"
Brad Bishop79641f22019-09-10 07:20:22 -040054
55 ptestsuite = "gcc-{}".format(suite) if suite != "gcc" else suite
56 ptestsuite = ptestsuite + "-user" if ssh is None else ptestsuite
Brad Bishopa34c0302019-09-23 22:34:48 -040057 self.ptest_section(ptestsuite, logfile = logpath)
Brad Bishop79641f22019-09-10 07:20:22 -040058 with open(sumspath, "r") as f:
59 for test, result in parse_values(f):
Brad Bishopa34c0302019-09-23 22:34:48 -040060 self.ptest_result(ptestsuite, test, result)
Brad Bishop79641f22019-09-10 07:20:22 -040061
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")
80class GccCrossSelfTest(GccSelfTestBase):
81 def test_cross_gcc(self):
Andrew Geissler82c905d2020-04-13 13:39:40 -050082 self.run_check("gcc")
83
84@OETestTag("toolchain-user")
85class GxxCrossSelfTest(GccSelfTestBase):
86 def test_cross_gxx(self):
87 self.run_check("g++")
Brad Bishop79641f22019-09-10 07:20:22 -040088
89@OETestTag("toolchain-user")
90class GccLibAtomicSelfTest(GccSelfTestBase):
91 def test_libatomic(self):
92 self.run_check("libatomic")
93
94@OETestTag("toolchain-user")
95class GccLibGompSelfTest(GccSelfTestBase):
96 def test_libgomp(self):
97 self.run_check("libgomp")
98
99@OETestTag("toolchain-user")
100class GccLibStdCxxSelfTest(GccSelfTestBase):
101 def test_libstdcxx(self):
102 self.run_check("libstdc++-v3")
103
104@OETestTag("toolchain-user")
105class GccLibSspSelfTest(GccSelfTestBase):
106 def test_libssp(self):
107 self.check_skip("libssp")
108 self.run_check("libssp")
109
110@OETestTag("toolchain-user")
111class GccLibItmSelfTest(GccSelfTestBase):
112 def test_libitm(self):
113 self.check_skip("libitm")
114 self.run_check("libitm")
115
116@OETestTag("toolchain-system")
Patrick Williams45852732022-04-02 08:58:32 -0500117@OETestTag("runqemu")
Brad Bishop79641f22019-09-10 07:20:22 -0400118class GccCrossSelfTestSystemEmulated(GccSelfTestBase):
119 def test_cross_gcc(self):
Andrew Geissler82c905d2020-04-13 13:39:40 -0500120 self.run_check_emulated("gcc")
121
122@OETestTag("toolchain-system")
Patrick Williams45852732022-04-02 08:58:32 -0500123@OETestTag("runqemu")
Andrew Geissler82c905d2020-04-13 13:39:40 -0500124class GxxCrossSelfTestSystemEmulated(GccSelfTestBase):
125 def test_cross_gxx(self):
126 self.run_check_emulated("g++")
Brad Bishop79641f22019-09-10 07:20:22 -0400127
128@OETestTag("toolchain-system")
Patrick Williams45852732022-04-02 08:58:32 -0500129@OETestTag("runqemu")
Brad Bishop79641f22019-09-10 07:20:22 -0400130class GccLibAtomicSelfTestSystemEmulated(GccSelfTestBase):
131 def test_libatomic(self):
132 self.run_check_emulated("libatomic")
133
134@OETestTag("toolchain-system")
Patrick Williams45852732022-04-02 08:58:32 -0500135@OETestTag("runqemu")
Brad Bishop79641f22019-09-10 07:20:22 -0400136class GccLibGompSelfTestSystemEmulated(GccSelfTestBase):
137 def test_libgomp(self):
138 self.run_check_emulated("libgomp")
139
140@OETestTag("toolchain-system")
Patrick Williams45852732022-04-02 08:58:32 -0500141@OETestTag("runqemu")
Brad Bishop79641f22019-09-10 07:20:22 -0400142class GccLibStdCxxSelfTestSystemEmulated(GccSelfTestBase):
143 def test_libstdcxx(self):
144 self.run_check_emulated("libstdc++-v3")
145
146@OETestTag("toolchain-system")
Patrick Williams45852732022-04-02 08:58:32 -0500147@OETestTag("runqemu")
Brad Bishop79641f22019-09-10 07:20:22 -0400148class GccLibSspSelfTestSystemEmulated(GccSelfTestBase):
149 def test_libssp(self):
150 self.check_skip("libssp")
151 self.run_check_emulated("libssp")
152
153@OETestTag("toolchain-system")
Patrick Williams45852732022-04-02 08:58:32 -0500154@OETestTag("runqemu")
Brad Bishop79641f22019-09-10 07:20:22 -0400155class GccLibItmSelfTestSystemEmulated(GccSelfTestBase):
156 def test_libitm(self):
157 self.check_skip("libitm")
158 self.run_check_emulated("libitm")
159