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 | |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 13 | |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 14 | class Debuginfod(OESelftestTestCase): |
| 15 | def test_debuginfod(self): |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 16 | self.write_config( |
| 17 | """ |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 18 | DISTRO_FEATURES:append = " debuginfod" |
| 19 | CORE_IMAGE_EXTRA_INSTALL += "elfutils" |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 20 | """ |
| 21 | ) |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 22 | bitbake("core-image-minimal elfutils-native:do_addto_recipe_sysroot") |
| 23 | |
| 24 | native_sysroot = get_bb_var("RECIPE_SYSROOT_NATIVE", "elfutils-native") |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 25 | cmd = [ |
| 26 | os.path.join(native_sysroot, "usr", "bin", "debuginfod"), |
| 27 | "--verbose", |
| 28 | "--database=:memory:", |
| 29 | get_bb_var("DEPLOY_DIR"), |
| 30 | ] |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 31 | 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 Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 47 | cmd = ( |
| 48 | "DEBUGINFOD_URLS=http://%s:%d/ debuginfod-find debuginfo /usr/bin/debuginfod" |
| 49 | % (qemu.server_ip, port) |
| 50 | ) |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 51 | status, output = qemu.run_serial(cmd) |
| 52 | # This should be more comprehensive |
| 53 | self.assertIn("/.cache/debuginfod_client/", output) |
| 54 | finally: |
| 55 | debuginfod.kill() |