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, get_bb_vars, 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 image = 'core-image-minimal' 21 bb_vars = get_bb_vars(['DEPLOY_DIR_IMAGE', 'IMAGE_LINK_NAME', 'READELF'], image) 22 23 self.write_config(""" 24DISTRO_FEATURES:append = " minidebuginfo" 25IMAGE_FSTYPES = "tar.bz2" 26""") 27 bitbake("{} {}:do_addto_recipe_sysroot".format(image, binutils)) 28 29 native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", binutils) 30 31 # confirm that executables and shared libraries contain an ELF section 32 # ".gnu_debugdata" which stores minidebuginfo. 33 with tempfile.TemporaryDirectory(prefix = "unpackfs-") as unpackedfs: 34 filename = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], "{}.tar.bz2".format(bb_vars['IMAGE_LINK_NAME'])) 35 shutil.unpack_archive(filename, unpackedfs) 36 37 r = runCmd([bb_vars['READELF'], "-W", "-S", os.path.join(unpackedfs, "bin", "busybox")], 38 native_sysroot = native_sysroot, target_sys = target_sys) 39 self.assertIn(".gnu_debugdata", r.output) 40 41 r = runCmd([bb_vars['READELF'], "-W", "-S", os.path.join(unpackedfs, "lib", "libc.so.6")], 42 native_sysroot = native_sysroot, target_sys = target_sys) 43 self.assertIn(".gnu_debugdata", r.output) 44 45