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 # confirm that executables and shared libraries contain an ELF section 31 # ".gnu_debugdata" which stores minidebuginfo. 32 with tempfile.TemporaryDirectory(prefix = "unpackfs-") as unpackedfs: 33 filename = os.path.join(deploy_dir, "core-image-minimal-{}.tar.bz2".format(self.td["MACHINE"])) 34 shutil.unpack_archive(filename, unpackedfs) 35 36 r = runCmd([readelf, "-W", "-S", os.path.join(unpackedfs, "bin", "busybox")], 37 native_sysroot = native_sysroot, target_sys = target_sys) 38 self.assertIn(".gnu_debugdata", r.output) 39 40 r = runCmd([readelf, "-W", "-S", os.path.join(unpackedfs, "lib", "libc.so.6")], 41 native_sysroot = native_sysroot, target_sys = target_sys) 42 self.assertIn(".gnu_debugdata", r.output) 43 44