summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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