blob: 89360178fec183e6b736fddaf55ddcfac698263b [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
Patrick Williams2a254922023-08-11 09:48:11 -05007import time
Brad Bishop79641f22019-09-10 07:20:22 -04008from oeqa.core.decorator import OETestTag
Brad Bishopa34c0302019-09-23 22:34:48 -04009from oeqa.core.case import OEPTestResultTestCase
Brad Bishop79641f22019-09-10 07:20:22 -040010from oeqa.selftest.case import OESelftestTestCase
Patrick Williams45852732022-04-02 08:58:32 -050011from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars, runqemu
Brad Bishop79641f22019-09-10 07:20:22 -040012
13def parse_values(content):
14 for i in content:
15 for v in ["PASS", "FAIL", "XPASS", "XFAIL", "UNRESOLVED", "UNSUPPORTED", "UNTESTED", "ERROR", "WARNING"]:
16 if i.startswith(v + ": "):
17 yield i[len(v) + 2:].strip(), v
18 break
19
Brad Bishopa34c0302019-09-23 22:34:48 -040020class GccSelfTestBase(OESelftestTestCase, OEPTestResultTestCase):
Brad Bishop79641f22019-09-10 07:20:22 -040021 def check_skip(self, suite):
22 targets = get_bb_var("RUNTIMETARGET", "gcc-runtime").split()
23 if suite not in targets:
24 self.skipTest("Target does not use {0}".format(suite))
25
26 def run_check(self, *suites, ssh = None):
27 targets = set()
28 for s in suites:
Andrew Geissler82c905d2020-04-13 13:39:40 -050029 if s == "gcc":
30 targets.add("check-gcc-c")
31 elif s == "g++":
32 targets.add("check-gcc-c++")
Brad Bishop79641f22019-09-10 07:20:22 -040033 else:
34 targets.add("check-target-{}".format(s))
35
36 # configure ssh target
37 features = []
38 features.append('MAKE_CHECK_TARGETS = "{0}"'.format(" ".join(targets)))
39 if ssh is not None:
40 features.append('TOOLCHAIN_TEST_TARGET = "ssh"')
41 features.append('TOOLCHAIN_TEST_HOST = "{0}"'.format(ssh))
42 features.append('TOOLCHAIN_TEST_HOST_USER = "root"')
43 features.append('TOOLCHAIN_TEST_HOST_PORT = "22"')
44 self.write_config("\n".join(features))
45
46 recipe = "gcc-runtime"
Patrick Williams2a254922023-08-11 09:48:11 -050047
48 start_time = time.time()
49
Brad Bishop79641f22019-09-10 07:20:22 -040050 bitbake("{} -c check".format(recipe))
51
Patrick Williams2a254922023-08-11 09:48:11 -050052 end_time = time.time()
53
Brad Bishop79641f22019-09-10 07:20:22 -040054 bb_vars = get_bb_vars(["B", "TARGET_SYS"], recipe)
55 builddir, target_sys = bb_vars["B"], bb_vars["TARGET_SYS"]
56
Brad Bishop79641f22019-09-10 07:20:22 -040057 for suite in suites:
58 sumspath = os.path.join(builddir, "gcc", "testsuite", suite, "{0}.sum".format(suite))
59 if not os.path.exists(sumspath): # check in target dirs
60 sumspath = os.path.join(builddir, target_sys, suite, "testsuite", "{0}.sum".format(suite))
61 if not os.path.exists(sumspath): # handle libstdc++-v3 -> libstdc++
62 sumspath = os.path.join(builddir, target_sys, suite, "testsuite", "{0}.sum".format(suite.split("-")[0]))
Brad Bishopa34c0302019-09-23 22:34:48 -040063 logpath = os.path.splitext(sumspath)[0] + ".log"
Brad Bishop79641f22019-09-10 07:20:22 -040064
65 ptestsuite = "gcc-{}".format(suite) if suite != "gcc" else suite
66 ptestsuite = ptestsuite + "-user" if ssh is None else ptestsuite
Patrick Williams2a254922023-08-11 09:48:11 -050067 self.ptest_section(ptestsuite, duration = int(end_time - start_time), logfile = logpath)
Brad Bishop79641f22019-09-10 07:20:22 -040068 with open(sumspath, "r") as f:
69 for test, result in parse_values(f):
Brad Bishopa34c0302019-09-23 22:34:48 -040070 self.ptest_result(ptestsuite, test, result)
Brad Bishop79641f22019-09-10 07:20:22 -040071
72 def run_check_emulated(self, *args, **kwargs):
73 # build core-image-minimal with required packages
74 default_installed_packages = ["libgcc", "libstdc++", "libatomic", "libgomp"]
75 features = []
76 features.append('IMAGE_FEATURES += "ssh-server-openssh"')
77 features.append('CORE_IMAGE_EXTRA_INSTALL += "{0}"'.format(" ".join(default_installed_packages)))
78 self.write_config("\n".join(features))
79 bitbake("core-image-minimal")
80
81 # wrap the execution with a qemu instance
82 with runqemu("core-image-minimal", runqemuparams = "nographic") as qemu:
83 # validate that SSH is working
84 status, _ = qemu.run("uname")
85 self.assertEqual(status, 0)
86
87 return self.run_check(*args, ssh=qemu.ip, **kwargs)
88
89@OETestTag("toolchain-user")
90class GccCrossSelfTest(GccSelfTestBase):
91 def test_cross_gcc(self):
Andrew Geissler82c905d2020-04-13 13:39:40 -050092 self.run_check("gcc")
93
94@OETestTag("toolchain-user")
95class GxxCrossSelfTest(GccSelfTestBase):
96 def test_cross_gxx(self):
97 self.run_check("g++")
Brad Bishop79641f22019-09-10 07:20:22 -040098
99@OETestTag("toolchain-user")
100class GccLibAtomicSelfTest(GccSelfTestBase):
101 def test_libatomic(self):
102 self.run_check("libatomic")
103
104@OETestTag("toolchain-user")
105class GccLibGompSelfTest(GccSelfTestBase):
106 def test_libgomp(self):
107 self.run_check("libgomp")
108
109@OETestTag("toolchain-user")
110class GccLibStdCxxSelfTest(GccSelfTestBase):
111 def test_libstdcxx(self):
112 self.run_check("libstdc++-v3")
113
114@OETestTag("toolchain-user")
115class GccLibSspSelfTest(GccSelfTestBase):
116 def test_libssp(self):
117 self.check_skip("libssp")
118 self.run_check("libssp")
119
120@OETestTag("toolchain-user")
121class GccLibItmSelfTest(GccSelfTestBase):
122 def test_libitm(self):
123 self.check_skip("libitm")
124 self.run_check("libitm")
125
126@OETestTag("toolchain-system")
Patrick Williams45852732022-04-02 08:58:32 -0500127@OETestTag("runqemu")
Brad Bishop79641f22019-09-10 07:20:22 -0400128class GccCrossSelfTestSystemEmulated(GccSelfTestBase):
129 def test_cross_gcc(self):
Andrew Geissler82c905d2020-04-13 13:39:40 -0500130 self.run_check_emulated("gcc")
131
132@OETestTag("toolchain-system")
Patrick Williams45852732022-04-02 08:58:32 -0500133@OETestTag("runqemu")
Andrew Geissler82c905d2020-04-13 13:39:40 -0500134class GxxCrossSelfTestSystemEmulated(GccSelfTestBase):
135 def test_cross_gxx(self):
136 self.run_check_emulated("g++")
Brad Bishop79641f22019-09-10 07:20:22 -0400137
138@OETestTag("toolchain-system")
Patrick Williams45852732022-04-02 08:58:32 -0500139@OETestTag("runqemu")
Brad Bishop79641f22019-09-10 07:20:22 -0400140class GccLibAtomicSelfTestSystemEmulated(GccSelfTestBase):
141 def test_libatomic(self):
142 self.run_check_emulated("libatomic")
143
144@OETestTag("toolchain-system")
Patrick Williams45852732022-04-02 08:58:32 -0500145@OETestTag("runqemu")
Brad Bishop79641f22019-09-10 07:20:22 -0400146class GccLibGompSelfTestSystemEmulated(GccSelfTestBase):
147 def test_libgomp(self):
148 self.run_check_emulated("libgomp")
149
150@OETestTag("toolchain-system")
Patrick Williams45852732022-04-02 08:58:32 -0500151@OETestTag("runqemu")
Brad Bishop79641f22019-09-10 07:20:22 -0400152class GccLibStdCxxSelfTestSystemEmulated(GccSelfTestBase):
153 def test_libstdcxx(self):
154 self.run_check_emulated("libstdc++-v3")
155
156@OETestTag("toolchain-system")
Patrick Williams45852732022-04-02 08:58:32 -0500157@OETestTag("runqemu")
Brad Bishop79641f22019-09-10 07:20:22 -0400158class GccLibSspSelfTestSystemEmulated(GccSelfTestBase):
159 def test_libssp(self):
160 self.check_skip("libssp")
161 self.run_check_emulated("libssp")
162
163@OETestTag("toolchain-system")
Patrick Williams45852732022-04-02 08:58:32 -0500164@OETestTag("runqemu")
Brad Bishop79641f22019-09-10 07:20:22 -0400165class GccLibItmSelfTestSystemEmulated(GccSelfTestBase):
166 def test_libitm(self):
167 self.check_skip("libitm")
168 self.run_check_emulated("libitm")
169