Add LLDB test driver and initial Debugger API tests#3120
Add LLDB test driver and initial Debugger API tests#3120patryk4815 merged 14 commits intopwndbg:devfrom
Conversation
b34c10b to
1f0e97a
Compare
|
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. |
fda33b2 to
a66db20
Compare
|
@mbrla0 pls fix conflicts |
There was a problem hiding this comment.
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.pyCLI 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 intotests/host/_collection_from_pytestand_result_from_pytest. - Add initial async Debugger API tests under
tests/library/dbg, plus support in shell and launcher scripts for passingTEST_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
argsis not defined in this scope, which will cause a runtime error. You likely meant to usebinary_pathor another parameter.
gdb.execute("starti " + " ".join(args))
tests/host/gdb/pytests_collect.py:8
- This file uses
osandsysbut neither module is imported at the top. Addimport osandimport sys.
PWNDBG_ROOT = os.environ.get("TEST_PWNDBG_ROOT")
tests/host/init.py:40
- _collection_from_pytest
uses theremodule butimport reis missing. Addimport re` at the top of this file.
pattern = re.compile(rf"{path_spec}.*::.*")
|
Rebased. |
Co-authored-by: Disconnect3d <[email protected]>
Co-authored-by: Disconnect3d <[email protected]>
tests/tests.py
Outdated
| """ | ||
| if args.nix: | ||
| # Use pwndbg, as built by nix. | ||
| lldbinit_dir = local_pwndbg_root / "result" / "share" / "pwndbg/" |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
it should be nix build .#pwndbg-lldb-dev with -dev suffix?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
TEST_PWNDBG_ROOT can be dropped when using relative imports
tests/library/dbg/tests/__init__.py
Outdated
|
|
||
|
|
||
| def pwndbg_test( | ||
| test: Callable[..., Coroutine[Any, Any, None]], |
There was a problem hiding this comment.
we should use typing.Concatenate here, to specify function must have first argument of type Controller
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.