blob: 6b9022e461995079ac40980617f021ba768a0145 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001#
2# Copyright OpenEmbedded Contributors
3#
Brad Bishop79641f22019-09-10 07:20:22 -04004# SPDX-License-Identifier: MIT
Patrick Williams92b42cb2022-09-03 06:53:57 -05005#
Brad Bishop79641f22019-09-10 07:20:22 -04006import os
7from oeqa.core.decorator import OETestTag
Brad Bishopa34c0302019-09-23 22:34:48 -04008from oeqa.core.case import OEPTestResultTestCase
Brad Bishop79641f22019-09-10 07:20:22 -04009from oeqa.selftest.case import OESelftestTestCase
Patrick Williams45852732022-04-02 08:58:32 -050010from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars, runqemu
Brad Bishop79641f22019-09-10 07:20:22 -040011
12def 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 Bishopa34c0302019-09-23 22:34:48 -040019class GccSelfTestBase(OESelftestTestCase, OEPTestResultTestCase):
Brad Bishop79641f22019-09-10 07:20:22 -040020 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 Geissler82c905d2020-04-13 13:39:40 -050028 if s == "gcc":
29 targets.add("check-gcc-c")
30 elif s == "g++":
31 targets.add("check-gcc-c++")
Brad Bishop79641f22019-09-10 07:20:22 -040032 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 Bishop79641f22019-09-10 07:20:22 -040051 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 Bishopa34c0302019-09-23 22:34:48 -040057 logpath = os.path.splitext(sumspath)[0] + ".log"
Brad Bishop79641f22019-09-10 07:20:22 -040058
59 ptestsuite = "gcc-{}".format(suite) if suite != "gcc" else suite
60 ptestsuite = ptestsuite + "-user" if ssh is None else ptestsuite
Brad Bishopa34c0302019-09-23 22:34:48 -040061 self.ptest_section(ptestsuite, logfile = logpath)
Brad Bishop79641f22019-09-10 07:20:22 -040062 with open(sumspath, "r") as f:
63 for test, result in parse_values(f):
Brad Bishopa34c0302019-09-23 22:34:48 -040064 self.ptest_result(ptestsuite, test, result)
Brad Bishop79641f22019-09-10 07:20:22 -040065
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")
84class GccCrossSelfTest(GccSelfTestBase):
85 def test_cross_gcc(self):
Andrew Geissler82c905d2020-04-13 13:39:40 -050086 self.run_check("gcc")
87
88@OETestTag("toolchain-user")
89class GxxCrossSelfTest(GccSelfTestBase):
90 def test_cross_gxx(self):
91 self.run_check("g++")
Brad Bishop79641f22019-09-10 07:20:22 -040092
93@OETestTag("toolchain-user")
94class GccLibAtomicSelfTest(GccSelfTestBase):
95 def test_libatomic(self):
96 self.run_check("libatomic")
97
98@OETestTag("toolchain-user")
99class GccLibGompSelfTest(GccSelfTestBase):
100 def test_libgomp(self):
101 self.run_check("libgomp")
102
103@OETestTag("toolchain-user")
104class GccLibStdCxxSelfTest(GccSelfTestBase):
105 def test_libstdcxx(self):
106 self.run_check("libstdc++-v3")
107
108@OETestTag("toolchain-user")
109class GccLibSspSelfTest(GccSelfTestBase):
110 def test_libssp(self):
111 self.check_skip("libssp")
112 self.run_check("libssp")
113
114@OETestTag("toolchain-user")
115class GccLibItmSelfTest(GccSelfTestBase):
116 def test_libitm(self):
117 self.check_skip("libitm")
118 self.run_check("libitm")
119
120@OETestTag("toolchain-system")
Patrick Williams45852732022-04-02 08:58:32 -0500121@OETestTag("runqemu")
Brad Bishop79641f22019-09-10 07:20:22 -0400122class GccCrossSelfTestSystemEmulated(GccSelfTestBase):
123 def test_cross_gcc(self):
Andrew Geissler82c905d2020-04-13 13:39:40 -0500124 self.run_check_emulated("gcc")
125
126@OETestTag("toolchain-system")
Patrick Williams45852732022-04-02 08:58:32 -0500127@OETestTag("runqemu")
Andrew Geissler82c905d2020-04-13 13:39:40 -0500128class GxxCrossSelfTestSystemEmulated(GccSelfTestBase):
129 def test_cross_gxx(self):
130 self.run_check_emulated("g++")
Brad Bishop79641f22019-09-10 07:20:22 -0400131
132@OETestTag("toolchain-system")
Patrick Williams45852732022-04-02 08:58:32 -0500133@OETestTag("runqemu")
Brad Bishop79641f22019-09-10 07:20:22 -0400134class GccLibAtomicSelfTestSystemEmulated(GccSelfTestBase):
135 def test_libatomic(self):
136 self.run_check_emulated("libatomic")
137
138@OETestTag("toolchain-system")
Patrick Williams45852732022-04-02 08:58:32 -0500139@OETestTag("runqemu")
Brad Bishop79641f22019-09-10 07:20:22 -0400140class GccLibGompSelfTestSystemEmulated(GccSelfTestBase):
141 def test_libgomp(self):
142 self.run_check_emulated("libgomp")
143
144@OETestTag("toolchain-system")
Patrick Williams45852732022-04-02 08:58:32 -0500145@OETestTag("runqemu")
Brad Bishop79641f22019-09-10 07:20:22 -0400146class GccLibStdCxxSelfTestSystemEmulated(GccSelfTestBase):
147 def test_libstdcxx(self):
148 self.run_check_emulated("libstdc++-v3")
149
150@OETestTag("toolchain-system")
Patrick Williams45852732022-04-02 08:58:32 -0500151@OETestTag("runqemu")
Brad Bishop79641f22019-09-10 07:20:22 -0400152class GccLibSspSelfTestSystemEmulated(GccSelfTestBase):
153 def test_libssp(self):
154 self.check_skip("libssp")
155 self.run_check_emulated("libssp")
156
157@OETestTag("toolchain-system")
Patrick Williams45852732022-04-02 08:58:32 -0500158@OETestTag("runqemu")
Brad Bishop79641f22019-09-10 07:20:22 -0400159class GccLibItmSelfTestSystemEmulated(GccSelfTestBase):
160 def test_libitm(self):
161 self.check_skip("libitm")
162 self.run_check_emulated("libitm")
163