diff options
author | Nathan Rossi <nathan@nathanrossi.com> | 2019-09-03 16:56:41 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-09-07 21:56:43 +0100 |
commit | 9b1fc819473e73fdb989a7dcb3484e8a49e4c565 (patch) | |
tree | dfc33635f21a2edda075c002cdfdae8cfe540b39 /meta/lib | |
parent | 60b2e6acad403a04e3c1bc2e30b82bb75f3f8288 (diff) | |
download | poky-9b1fc819473e73fdb989a7dcb3484e8a49e4c565.tar.gz |
oeqa/selftest/glibc: Create selftest case for glibc test suite
Create a oeqa selftest test case to execute the glibc test suite 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 GlibcSelfTestSystemEmulated test case
handles setup of the target image, setup of and NFS server as well as
execution with runqemu.
(From OE-Core rev: 730832ebcca305477e1c13248cd35eea095b35c6)
Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/glibc.py | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/glibc.py b/meta/lib/oeqa/selftest/cases/glibc.py new file mode 100644 index 0000000000..f836367094 --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/glibc.py | |||
@@ -0,0 +1,97 @@ | |||
1 | # SPDX-License-Identifier: MIT | ||
2 | import os | ||
3 | import contextlib | ||
4 | from oeqa.core.decorator import OETestTag | ||
5 | from oeqa.selftest.case import OESelftestTestCase | ||
6 | from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars, runqemu, Command | ||
7 | from oeqa.utils.nfs import unfs_server | ||
8 | |||
9 | def parse_values(content): | ||
10 | for i in content: | ||
11 | for v in ["PASS", "FAIL", "XPASS", "XFAIL", "UNRESOLVED", "UNSUPPORTED", "UNTESTED", "ERROR", "WARNING"]: | ||
12 | if i.startswith(v + ": "): | ||
13 | yield i[len(v) + 2:].strip(), v | ||
14 | break | ||
15 | |||
16 | @OETestTag("machine") | ||
17 | class GlibcSelfTest(OESelftestTestCase): | ||
18 | @classmethod | ||
19 | def setUpClass(cls): | ||
20 | super().setUpClass() | ||
21 | if not hasattr(cls.tc, "extraresults"): | ||
22 | cls.tc.extraresults = {} | ||
23 | |||
24 | if "ptestresult.sections" not in cls.tc.extraresults: | ||
25 | cls.tc.extraresults["ptestresult.sections"] = {} | ||
26 | |||
27 | def test_glibc(self): | ||
28 | self.glibc_run_check() | ||
29 | |||
30 | def glibc_run_check(self, ssh = None): | ||
31 | # configure ssh target | ||
32 | features = [] | ||
33 | if ssh is not None: | ||
34 | features.append('TOOLCHAIN_TEST_TARGET = "ssh"') | ||
35 | features.append('TOOLCHAIN_TEST_HOST = "{0}"'.format(ssh)) | ||
36 | features.append('TOOLCHAIN_TEST_HOST_USER = "root"') | ||
37 | features.append('TOOLCHAIN_TEST_HOST_PORT = "22"') | ||
38 | # force single threaded test execution | ||
39 | features.append('EGLIBCPARALLELISM_task-check_pn-glibc-testsuite = "PARALLELMFLAGS="-j1""') | ||
40 | self.write_config("\n".join(features)) | ||
41 | |||
42 | bitbake("glibc-testsuite -c check") | ||
43 | |||
44 | builddir = get_bb_var("B", "glibc-testsuite") | ||
45 | |||
46 | failed = 0 | ||
47 | self.tc.extraresults["ptestresult.sections"]["glibc"] = {} | ||
48 | with open(os.path.join(builddir, "tests.sum"), "r") as f: | ||
49 | for test, result in parse_values(f): | ||
50 | self.tc.extraresults["ptestresult.glibc.{}".format(test)] = {"status" : result} | ||
51 | if result == "FAIL": | ||
52 | self.logger.info("failed: '{}'".format(test)) | ||
53 | failed += 1 | ||
54 | self.assertEqual(failed, 0) | ||
55 | |||
56 | class GlibcSelfTestSystemEmulated(GlibcSelfTest): | ||
57 | default_installed_packages = [ | ||
58 | "glibc-charmaps", | ||
59 | "libgcc", | ||
60 | "libstdc++", | ||
61 | "libatomic", | ||
62 | "libgomp", | ||
63 | "python3", | ||
64 | "python3-pexpect", | ||
65 | "nfs-utils", | ||
66 | ] | ||
67 | |||
68 | def glibc_run_check(self): | ||
69 | with contextlib.ExitStack() as s: | ||
70 | # use the base work dir, as the nfs mount, since the recipe directory may not exist | ||
71 | tmpdir = get_bb_var("BASE_WORKDIR") | ||
72 | nfsport, mountport = s.enter_context(unfs_server(tmpdir)) | ||
73 | |||
74 | # build core-image-minimal with required packages | ||
75 | features = [] | ||
76 | features.append('IMAGE_FEATURES += "ssh-server-openssh"') | ||
77 | features.append('CORE_IMAGE_EXTRA_INSTALL += "{0}"'.format(" ".join(self.default_installed_packages))) | ||
78 | self.write_config("\n".join(features)) | ||
79 | bitbake("core-image-minimal") | ||
80 | |||
81 | # start runqemu | ||
82 | qemu = s.enter_context(runqemu("core-image-minimal", runqemuparams = "nographic")) | ||
83 | |||
84 | # validate that SSH is working | ||
85 | status, _ = qemu.run("uname") | ||
86 | self.assertEqual(status, 0) | ||
87 | |||
88 | # setup nfs mount | ||
89 | if qemu.run("mkdir -p \"{0}\"".format(tmpdir))[0] != 0: | ||
90 | raise Exception("Failed to setup NFS mount directory on target") | ||
91 | mountcmd = "mount -o noac,nfsvers=3,port={0},udp,mountport={1} \"{2}:{3}\" \"{3}\"".format(nfsport, mountport, qemu.server_ip, tmpdir) | ||
92 | status, output = qemu.run(mountcmd) | ||
93 | if status != 0: | ||
94 | raise Exception("Failed to setup NFS mount on target ({})".format(repr(output))) | ||
95 | |||
96 | super().glibc_run_check(ssh = qemu.ip) | ||
97 | |||