blob: 5a917b9c44926ccd6c3de23685ce291df712e630 [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
6from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars, runqemu, Command
7
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:
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 Bishop79641f22019-09-10 07:20:22 -040045 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 Bishopa34c0302019-09-23 22:34:48 -040051 logpath = os.path.splitext(sumspath)[0] + ".log"
Brad Bishop79641f22019-09-10 07:20:22 -040052
53 ptestsuite = "gcc-{}".format(suite) if suite != "gcc" else suite
54 ptestsuite = ptestsuite + "-user" if ssh is None else ptestsuite
Brad Bishopa34c0302019-09-23 22:34:48 -040055 self.ptest_section(ptestsuite, logfile = logpath)
Brad Bishop79641f22019-09-10 07:20:22 -040056 with open(sumspath, "r") as f:
57 for test, result in parse_values(f):
Brad Bishopa34c0302019-09-23 22:34:48 -040058 self.ptest_result(ptestsuite, test, result)
Brad Bishop79641f22019-09-10 07:20:22 -040059
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")
78class GccCrossSelfTest(GccSelfTestBase):
79 def test_cross_gcc(self):
80 self.run_check("gcc", "g++")
81
82@OETestTag("toolchain-user")
83class GccLibAtomicSelfTest(GccSelfTestBase):
84 def test_libatomic(self):
85 self.run_check("libatomic")
86
87@OETestTag("toolchain-user")
88class GccLibGompSelfTest(GccSelfTestBase):
89 def test_libgomp(self):
90 self.run_check("libgomp")
91
92@OETestTag("toolchain-user")
93class GccLibStdCxxSelfTest(GccSelfTestBase):
94 def test_libstdcxx(self):
95 self.run_check("libstdc++-v3")
96
97@OETestTag("toolchain-user")
98class GccLibSspSelfTest(GccSelfTestBase):
99 def test_libssp(self):
100 self.check_skip("libssp")
101 self.run_check("libssp")
102
103@OETestTag("toolchain-user")
104class GccLibItmSelfTest(GccSelfTestBase):
105 def test_libitm(self):
106 self.check_skip("libitm")
107 self.run_check("libitm")
108
109@OETestTag("toolchain-system")
110class GccCrossSelfTestSystemEmulated(GccSelfTestBase):
111 def test_cross_gcc(self):
112 self.run_check_emulated("gcc", "g++")
113
114@OETestTag("toolchain-system")
115class GccLibAtomicSelfTestSystemEmulated(GccSelfTestBase):
116 def test_libatomic(self):
117 self.run_check_emulated("libatomic")
118
119@OETestTag("toolchain-system")
120class GccLibGompSelfTestSystemEmulated(GccSelfTestBase):
121 def test_libgomp(self):
122 self.run_check_emulated("libgomp")
123
124@OETestTag("toolchain-system")
125class GccLibStdCxxSelfTestSystemEmulated(GccSelfTestBase):
126 def test_libstdcxx(self):
127 self.run_check_emulated("libstdc++-v3")
128
129@OETestTag("toolchain-system")
130class GccLibSspSelfTestSystemEmulated(GccSelfTestBase):
131 def test_libssp(self):
132 self.check_skip("libssp")
133 self.run_check_emulated("libssp")
134
135@OETestTag("toolchain-system")
136class GccLibItmSelfTestSystemEmulated(GccSelfTestBase):
137 def test_libitm(self):
138 self.check_skip("libitm")
139 self.run_check_emulated("libitm")
140