summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Rossi <nathan.rossi@digi.com>2022-11-14 08:17:18 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-11-24 15:30:00 +0000
commitca97e3568e32ca58c4bc59b4cfb5a53592ad3a2e (patch)
tree4dd1ed35fbc457aae79aff403191309c244c0ec8
parent9cf631a08379ca2609c60518e4644dd2e615a0a2 (diff)
downloadpoky-ca97e3568e32ca58c4bc59b4cfb5a53592ad3a2e.tar.gz
oeqa/selftest/minidebuginfo: Create selftest for minidebuginfo
Add a new selftest to validate minidebuginfo support. This selftest builds a complete target image with PACKAGE_MINIDEBUGINFO enabled. ELFs included in the image are expected to have minidebuginfo included in the resulting executables and shared libraries, the self test validates this by unpacking the image and checking for the associated ".gnu_debugdata" section on busybox and libc ELFs. (From OE-Core rev: e7b0b23fd8357456ba41fe8d222f10313536d2d3) Signed-off-by: Nathan Rossi <nathan.rossi@digi.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> (cherry picked from commit 5063a31ad05b75ec6ac12158fe759e81fcdb1585) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/selftest/cases/minidebuginfo.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/minidebuginfo.py b/meta/lib/oeqa/selftest/cases/minidebuginfo.py
new file mode 100644
index 0000000000..414dad64a3
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/minidebuginfo.py
@@ -0,0 +1,49 @@
1#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6import os
7import subprocess
8import tempfile
9import shutil
10
11from oeqa.selftest.case import OESelftestTestCase
12from oeqa.utils.commands import bitbake, get_bb_var, runCmd
13
14
15class Minidebuginfo(OESelftestTestCase):
16 def test_minidebuginfo(self):
17 target_sys = get_bb_var("TARGET_SYS")
18 binutils = "binutils-cross-{}".format(get_bb_var("TARGET_ARCH"))
19
20 self.write_config("""
21PACKAGE_MINIDEBUGINFO = "1"
22IMAGE_FSTYPES = "tar.bz2"
23""")
24 bitbake("core-image-minimal {}:do_addto_recipe_sysroot".format(binutils))
25
26 deploy_dir = get_bb_var("DEPLOY_DIR_IMAGE")
27 native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", binutils)
28 readelf = get_bb_var("READELF", "core-image-minimal")
29
30 # add usr/bin/${TARGET_SYS} to PATH
31 env = os.environ.copy()
32 paths = [os.path.join(native_sysroot, "usr", "bin", target_sys)]
33 paths += env["PATH"].split(":")
34 env["PATH"] = ":".join(paths)
35
36 # confirm that executables and shared libraries contain an ELF section
37 # ".gnu_debugdata" which stores minidebuginfo.
38 with tempfile.TemporaryDirectory(prefix = "unpackfs-") as unpackedfs:
39 filename = os.path.join(deploy_dir, "core-image-minimal-{}.tar.bz2".format(self.td["MACHINE"]))
40 shutil.unpack_archive(filename, unpackedfs)
41
42 r = runCmd([readelf, "-W", "-S", os.path.join(unpackedfs, "bin", "busybox")],
43 native_sysroot = native_sysroot, env = env)
44 self.assertIn(".gnu_debugdata", r.output)
45
46 r = runCmd([readelf, "-W", "-S", os.path.join(unpackedfs, "lib", "libc.so.6")],
47 native_sysroot = native_sysroot, env = env)
48 self.assertIn(".gnu_debugdata", r.output)
49