Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Comments

Add LLDB test driver and initial Debugger API tests#3120

Merged
patryk4815 merged 14 commits intopwndbg:devfrom
mbrla0:rework-tests-1
Jul 18, 2025
Merged

Add LLDB test driver and initial Debugger API tests#3120
patryk4815 merged 14 commits intopwndbg:devfrom
mbrla0:rework-tests-1

Conversation

@mbrla0
Copy link
Member

@mbrla0 mbrla0 commented Jun 19, 2025

This PR expands the reworked testing structure from #3101 so that it supports running tests using LLDB as well as GDB, and adds the first few Debugger-agnostic tests - that currently only check launching - that can be run under either debugger.

@mbrla0 mbrla0 force-pushed the rework-tests-1 branch 3 times, most recently from b34c10b to 1f0e97a Compare June 20, 2025 17:45
@mbrla0 mbrla0 marked this pull request as ready for review June 20, 2025 18:10
@mbrla0
Copy link
Member Author

mbrla0 commented Jun 20, 2025

Originally planned to integrate the new tests into the CI pipeline before I marked it as ready for review, but decided that's probably better off as its own PR.

@mbrla0 mbrla0 force-pushed the rework-tests-1 branch 3 times, most recently from fda33b2 to a66db20 Compare June 20, 2025 19:58
@disconnect3d disconnect3d requested a review from Copilot June 25, 2025 11:02
@disconnect3d
Copy link
Member

@mbrla0 pls fix conflicts

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR integrates LLDB into the existing test framework, refactors shared test collection/result logic, and introduces the first Debugger API tests that can run under both GDB and LLDB.

  • Add a unified tests/tests.py CLI driver supporting parallel/serial execution, code coverage, and both GDB/LLDB backends.
  • Implement an LLDB-based TestHost (tests/host/lldb) and refactor common collection/result handling into tests/host/_collection_from_pytest and _result_from_pytest.
  • Add initial async Debugger API tests under tests/library/dbg, plus support in shell and launcher scripts for passing TEST_PWNDBG_ROOT.

Reviewed Changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/tests.py New top-level test runner with argument parsing and parallel execution
tests/library/qemu-system/system-tests.sh Pass TEST_PWNDBG_ROOT to GDB invocations in QEMU system tests
tests/library/dbg/tests/test_test.py First async Debugger API tests (launch & decorator behavior)
tests/library/dbg/tests/init.py pwndbg_test decorator & binary lookup helper
tests/host/lldb/launch-guest.py LLDB launch guest script wiring into pytest
tests/host/lldb/init.py LLDBTestHost implementation
tests/host/gdb/pytests_launcher.py GDB async controller launcher adjustments
tests/host/gdb/pytests_collect.py GDB pytest collection script updates
tests/host/gdb/init.py Refactor GDB host to use shared collection/result helpers
tests/host/init.py Extract _collection_from_pytest and _result_from_pytest helpers
pwndbg/dbg/lldb/repl/init.py Adjust run signature to accept extra args for LLDB controllers
pwndbg-lldb.py Refactor into launch entrypoint and clean up main
Comments suppressed due to low confidence (3)

tests/host/gdb/pytests_launcher.py:38

  • The variable args is not defined in this scope, which will cause a runtime error. You likely meant to use binary_path or another parameter.
        gdb.execute("starti " + " ".join(args))

tests/host/gdb/pytests_collect.py:8

  • This file uses os and sys but neither module is imported at the top. Add import os and import sys.
PWNDBG_ROOT = os.environ.get("TEST_PWNDBG_ROOT")

tests/host/init.py:40

  • _collection_from_pytestuses theremodule butimport reis missing. Addimport re` at the top of this file.
    pattern = re.compile(rf"{path_spec}.*::.*")

@mbrla0
Copy link
Member Author

mbrla0 commented Jun 25, 2025

Rebased.

@disconnect3d disconnect3d requested a review from patryk4815 June 29, 2025 14:04
tests/tests.py Outdated
"""
if args.nix:
# Use pwndbg, as built by nix.
lldbinit_dir = local_pwndbg_root / "result" / "share" / "pwndbg/"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this directory not exists

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's from before we moved most of pwndbg into a package. The whole LLDB Nix code path in this PR is kind of useless after it. How does taking it out and fixing the Nix integration in a later PR sound?

tests/tests.py Outdated
lldbinit_dir = local_pwndbg_root / "result" / "share" / "pwndbg/"

if not lldbinit_dir.exists():
print("ERROR: No nix-compatible pwndbg found. Run nix build .#pwndbg-lldb")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be nix build .#pwndbg-lldb-dev with -dev suffix?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as this PR goes, pwndbg-lldb and pwndbg-lldb-dev work the same. But the next few PRs do change it to pwndbg-lldb-dev down the line.

env["PWNDBG_DISABLE_COLORS"] = "1"
env["GDB_BIN_PATH"] = str(self._gdb_path)
env["TEST_BINARIES_ROOT"] = str(self._binaries_root)
env["TEST_PWNDBG_ROOT"] = str(self._pwndbg_root)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TEST_PWNDBG_ROOT can be dropped when using relative imports



def pwndbg_test(
test: Callable[..., Coroutine[Any, Any, None]],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use typing.Concatenate here, to specify function must have first argument of type Controller

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good now?

@patryk4815 patryk4815 enabled auto-merge (squash) July 18, 2025 01:30
@patryk4815 patryk4815 merged commit 365af33 into pwndbg:dev Jul 18, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants