diff options
-rw-r--r-- | meta/lib/oeqa/selftest/cases/gcc.py | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/gcc.py b/meta/lib/oeqa/selftest/cases/gcc.py new file mode 100644 index 0000000000..0b0157e568 --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/gcc.py | |||
@@ -0,0 +1,111 @@ | |||
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 | @OETestTag("machine") | ||
15 | class GccSelfTest(OESelftestTestCase): | ||
16 | @classmethod | ||
17 | def setUpClass(cls): | ||
18 | super().setUpClass() | ||
19 | if not hasattr(cls.tc, "extraresults"): | ||
20 | cls.tc.extraresults = {} | ||
21 | |||
22 | if "ptestresult.sections" not in cls.tc.extraresults: | ||
23 | cls.tc.extraresults["ptestresult.sections"] = {} | ||
24 | |||
25 | def gcc_runtime_check_skip(self, suite): | ||
26 | targets = get_bb_var("RUNTIMETARGET", "gcc-runtime").split() | ||
27 | if suite not in targets: | ||
28 | self.skipTest("Target does not use {0}".format(suite)) | ||
29 | |||
30 | def test_cross_gcc(self): | ||
31 | self.gcc_run_check("gcc", "g++") | ||
32 | |||
33 | def test_libatomic(self): | ||
34 | self.gcc_run_check("libatomic") | ||
35 | |||
36 | def test_libgomp(self): | ||
37 | self.gcc_run_check("libgomp") | ||
38 | |||
39 | def test_libstdcxx(self): | ||
40 | self.gcc_run_check("libstdc++-v3") | ||
41 | |||
42 | def test_libssp(self): | ||
43 | self.gcc_runtime_check_skip("libssp") | ||
44 | self.gcc_run_check("libssp") | ||
45 | |||
46 | def test_libitm(self): | ||
47 | self.gcc_runtime_check_skip("libitm") | ||
48 | self.gcc_run_check("libitm") | ||
49 | |||
50 | def gcc_run_check(self, *suites, ssh = None): | ||
51 | targets = set() | ||
52 | for s in suites: | ||
53 | if s in ["gcc", "g++"]: | ||
54 | targets.add("check-gcc") | ||
55 | else: | ||
56 | targets.add("check-target-{}".format(s)) | ||
57 | |||
58 | # configure ssh target | ||
59 | features = [] | ||
60 | features.append('MAKE_CHECK_TARGETS = "{0}"'.format(" ".join(targets))) | ||
61 | if ssh is not None: | ||
62 | features.append('TOOLCHAIN_TEST_TARGET = "ssh"') | ||
63 | features.append('TOOLCHAIN_TEST_HOST = "{0}"'.format(ssh)) | ||
64 | features.append('TOOLCHAIN_TEST_HOST_USER = "root"') | ||
65 | features.append('TOOLCHAIN_TEST_HOST_PORT = "22"') | ||
66 | self.write_config("\n".join(features)) | ||
67 | |||
68 | recipe = "gcc-runtime" | ||
69 | bitbake("{} -c check".format(recipe)) | ||
70 | |||
71 | bb_vars = get_bb_vars(["B", "TARGET_SYS"], recipe) | ||
72 | builddir, target_sys = bb_vars["B"], bb_vars["TARGET_SYS"] | ||
73 | |||
74 | failed = 0 | ||
75 | for suite in suites: | ||
76 | sumspath = os.path.join(builddir, "gcc", "testsuite", suite, "{0}.sum".format(suite)) | ||
77 | if not os.path.exists(sumspath): # check in target dirs | ||
78 | sumspath = os.path.join(builddir, target_sys, suite, "testsuite", "{0}.sum".format(suite)) | ||
79 | if not os.path.exists(sumspath): # handle libstdc++-v3 -> libstdc++ | ||
80 | sumspath = os.path.join(builddir, target_sys, suite, "testsuite", "{0}.sum".format(suite.split("-")[0])) | ||
81 | |||
82 | ptestsuite = "gcc-{}".format(suite) if suite != "gcc" else suite | ||
83 | self.tc.extraresults["ptestresult.sections"][ptestsuite] = {} | ||
84 | with open(sumspath, "r") as f: | ||
85 | for test, result in parse_values(f): | ||
86 | self.tc.extraresults["ptestresult.{}.{}".format(ptestsuite, test)] = {"status" : result} | ||
87 | if result == "FAIL": | ||
88 | self.logger.info("failed: '{}'".format(test)) | ||
89 | failed += 1 | ||
90 | |||
91 | self.assertEqual(failed, 0) | ||
92 | |||
93 | class GccSelfTestSystemEmulated(GccSelfTest): | ||
94 | default_installed_packages = ["libgcc", "libstdc++", "libatomic", "libgomp"] | ||
95 | |||
96 | def gcc_run_check(self, *args, **kwargs): | ||
97 | # build core-image-minimal with required packages | ||
98 | features = [] | ||
99 | features.append('IMAGE_FEATURES += "ssh-server-openssh"') | ||
100 | features.append('CORE_IMAGE_EXTRA_INSTALL += "{0}"'.format(" ".join(self.default_installed_packages))) | ||
101 | self.write_config("\n".join(features)) | ||
102 | bitbake("core-image-minimal") | ||
103 | |||
104 | # wrap the execution with a qemu instance | ||
105 | with runqemu("core-image-minimal", runqemuparams = "nographic") as qemu: | ||
106 | # validate that SSH is working | ||
107 | status, _ = qemu.run("uname") | ||
108 | self.assertEqual(status, 0) | ||
109 | |||
110 | return super().gcc_run_check(*args, ssh=qemu.ip, **kwargs) | ||
111 | |||