summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest
diff options
context:
space:
mode:
authorNathan Rossi <nathan@nathanrossi.com>2019-09-03 16:56:41 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-09-07 21:56:43 +0100
commit60b2e6acad403a04e3c1bc2e30b82bb75f3f8288 (patch)
tree32e282cf0fe3513ebc322e33bf05e54bfd42491b /meta/lib/oeqa/selftest
parentd8f39cc971cb43a6660803eb717103c85ffaeb28 (diff)
downloadpoky-60b2e6acad403a04e3c1bc2e30b82bb75f3f8288.tar.gz
oeqa/selftest/gcc: Create selftest case for gcc test suite
Create a oeqa selftest test case to execute the gcc test suites and report the results. The results are populated into the extraresults variable of the test case which are written to testresults.json for resulttool to analyse. An additional subclass is created to separate the execution with qemu linux-user and qemu system. The GccSelfTestSystemEmulated test case handles setup of the target image as well as execution with runqemu. (From OE-Core rev: 2c86a25f8992243311e7fa1a8654b41f12b749de) Signed-off-by: Nathan Rossi <nathan@nathanrossi.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest')
-rw-r--r--meta/lib/oeqa/selftest/cases/gcc.py111
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
2import os
3from oeqa.core.decorator import OETestTag
4from oeqa.selftest.case import OESelftestTestCase
5from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars, runqemu, Command
6
7def 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")
15class 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
93class 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