Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 1 | # |
| 2 | # Copyright OpenEmbedded Contributors |
| 3 | # |
| 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
| 6 | import os |
| 7 | import socketserver |
| 8 | import subprocess |
| 9 | |
| 10 | from oeqa.selftest.case import OESelftestTestCase |
| 11 | from oeqa.utils.commands import bitbake, get_bb_var, runqemu |
| 12 | |
| 13 | class Debuginfod(OESelftestTestCase): |
| 14 | def test_debuginfod(self): |
| 15 | self.write_config(""" |
| 16 | DISTRO_FEATURES:append = " debuginfod" |
| 17 | CORE_IMAGE_EXTRA_INSTALL += "elfutils" |
| 18 | """) |
| 19 | bitbake("core-image-minimal elfutils-native:do_addto_recipe_sysroot") |
| 20 | |
| 21 | native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "elfutils-native") |
| 22 | cmd = [os.path.join(native_sysroot, "usr", "bin", "debuginfod"), "--verbose", get_bb_var("DEPLOY_DIR")] |
| 23 | for format in get_bb_var("PACKAGE_CLASSES").split(): |
| 24 | if format == "package_deb": |
| 25 | cmd.append("--scan-deb-dir") |
| 26 | elif format == "package_ipk": |
| 27 | cmd.append("--scan-deb-dir") |
| 28 | elif format == "package_rpm": |
| 29 | cmd.append("--scan-rpm-dir") |
| 30 | # Find a free port |
| 31 | with socketserver.TCPServer(("localhost", 0), None) as s: |
| 32 | port = s.server_address[1] |
| 33 | cmd.append("--port=%d" % port) |
| 34 | |
| 35 | try: |
| 36 | debuginfod = subprocess.Popen(cmd) |
| 37 | |
| 38 | with runqemu("core-image-minimal", runqemuparams="nographic") as qemu: |
| 39 | cmd = "DEBUGINFOD_URLS=http://%s:%d/ debuginfod-find debuginfo /usr/bin/debuginfod" % (qemu.server_ip, port) |
| 40 | status, output = qemu.run_serial(cmd) |
| 41 | # This should be more comprehensive |
| 42 | self.assertIn("/.cache/debuginfod_client/", output) |
| 43 | finally: |
| 44 | debuginfod.kill() |