blob: 3c401192829865aa5264cf220cb9fa1cb3a7a1ac [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6import os
7import socketserver
8import subprocess
9
10from oeqa.selftest.case import OESelftestTestCase
11from oeqa.utils.commands import bitbake, get_bb_var, runqemu
12
Andrew Geissler87f5cff2022-09-30 13:13:31 -050013
Patrick Williams92b42cb2022-09-03 06:53:57 -050014class Debuginfod(OESelftestTestCase):
15 def test_debuginfod(self):
Andrew Geissler87f5cff2022-09-30 13:13:31 -050016 self.write_config(
17 """
Patrick Williams92b42cb2022-09-03 06:53:57 -050018DISTRO_FEATURES:append = " debuginfod"
19CORE_IMAGE_EXTRA_INSTALL += "elfutils"
Andrew Geissler87f5cff2022-09-30 13:13:31 -050020 """
21 )
Patrick Williams92b42cb2022-09-03 06:53:57 -050022 bitbake("core-image-minimal elfutils-native:do_addto_recipe_sysroot")
23
24 native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "elfutils-native")
Andrew Geissler87f5cff2022-09-30 13:13:31 -050025 cmd = [
26 os.path.join(native_sysroot, "usr", "bin", "debuginfod"),
27 "--verbose",
28 "--database=:memory:",
29 get_bb_var("DEPLOY_DIR"),
30 ]
Patrick Williams92b42cb2022-09-03 06:53:57 -050031 for format in get_bb_var("PACKAGE_CLASSES").split():
32 if format == "package_deb":
33 cmd.append("--scan-deb-dir")
34 elif format == "package_ipk":
35 cmd.append("--scan-deb-dir")
36 elif format == "package_rpm":
37 cmd.append("--scan-rpm-dir")
38 # Find a free port
39 with socketserver.TCPServer(("localhost", 0), None) as s:
40 port = s.server_address[1]
41 cmd.append("--port=%d" % port)
42
43 try:
44 debuginfod = subprocess.Popen(cmd)
45
46 with runqemu("core-image-minimal", runqemuparams="nographic") as qemu:
Andrew Geissler87f5cff2022-09-30 13:13:31 -050047 cmd = (
48 "DEBUGINFOD_URLS=http://%s:%d/ debuginfod-find debuginfo /usr/bin/debuginfod"
49 % (qemu.server_ip, port)
50 )
Patrick Williams92b42cb2022-09-03 06:53:57 -050051 status, output = qemu.run_serial(cmd)
52 # This should be more comprehensive
53 self.assertIn("/.cache/debuginfod_client/", output)
54 finally:
55 debuginfod.kill()