mirror of
https://git.yoctoproject.org/poky
synced 2026-04-04 23:02:22 +02:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
9cf631a083
commit
ca97e3568e
49
meta/lib/oeqa/selftest/cases/minidebuginfo.py
Normal file
49
meta/lib/oeqa/selftest/cases/minidebuginfo.py
Normal file
@@ -0,0 +1,49 @@
|
||||
#
|
||||
# Copyright OpenEmbedded Contributors
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
import shutil
|
||||
|
||||
from oeqa.selftest.case import OESelftestTestCase
|
||||
from oeqa.utils.commands import bitbake, get_bb_var, runCmd
|
||||
|
||||
|
||||
class Minidebuginfo(OESelftestTestCase):
|
||||
def test_minidebuginfo(self):
|
||||
target_sys = get_bb_var("TARGET_SYS")
|
||||
binutils = "binutils-cross-{}".format(get_bb_var("TARGET_ARCH"))
|
||||
|
||||
self.write_config("""
|
||||
PACKAGE_MINIDEBUGINFO = "1"
|
||||
IMAGE_FSTYPES = "tar.bz2"
|
||||
""")
|
||||
bitbake("core-image-minimal {}:do_addto_recipe_sysroot".format(binutils))
|
||||
|
||||
deploy_dir = get_bb_var("DEPLOY_DIR_IMAGE")
|
||||
native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", binutils)
|
||||
readelf = get_bb_var("READELF", "core-image-minimal")
|
||||
|
||||
# add usr/bin/${TARGET_SYS} to PATH
|
||||
env = os.environ.copy()
|
||||
paths = [os.path.join(native_sysroot, "usr", "bin", target_sys)]
|
||||
paths += env["PATH"].split(":")
|
||||
env["PATH"] = ":".join(paths)
|
||||
|
||||
# confirm that executables and shared libraries contain an ELF section
|
||||
# ".gnu_debugdata" which stores minidebuginfo.
|
||||
with tempfile.TemporaryDirectory(prefix = "unpackfs-") as unpackedfs:
|
||||
filename = os.path.join(deploy_dir, "core-image-minimal-{}.tar.bz2".format(self.td["MACHINE"]))
|
||||
shutil.unpack_archive(filename, unpackedfs)
|
||||
|
||||
r = runCmd([readelf, "-W", "-S", os.path.join(unpackedfs, "bin", "busybox")],
|
||||
native_sysroot = native_sysroot, env = env)
|
||||
self.assertIn(".gnu_debugdata", r.output)
|
||||
|
||||
r = runCmd([readelf, "-W", "-S", os.path.join(unpackedfs, "lib", "libc.so.6")],
|
||||
native_sysroot = native_sysroot, env = env)
|
||||
self.assertIn(".gnu_debugdata", r.output)
|
||||
|
||||
Reference in New Issue
Block a user