Modify python test scripts to work from nix (#2168)

* Modify python test scripts to work from nix

* Update utils.py

* address review feedback

---------

Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
pull/2172/head
Aaron Adams 2 years ago committed by GitHub
parent 6b3f8155ea
commit 5d083d471c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -5,6 +5,7 @@ import concurrent.futures
import os
import re
import subprocess
import sys
import time
from subprocess import CompletedProcess
from typing import Tuple
@ -158,6 +159,11 @@ def parse_args():
parser.add_argument(
"-s", "--serial", action="store_true", help="run tests one at a time instead of in parallel"
)
parser.add_argument(
"--nix",
action="store_true",
help="run tests using gdbinit.py built for nix environment",
)
parser.add_argument(
"--collect-only",
action="store_true",
@ -176,6 +182,13 @@ if __name__ == "__main__":
if args.pdb:
print("Will run tests in serial and with Python debugger")
args.serial = True
if args.nix:
gdbinit_path = os.path.join(ROOT_DIR, "result/share/pwndbg/gdbinit.py")
if not os.path.exists(gdbinit_path):
print("ERROR: No nix-compatible gdbinit.py found. Run nix build .#pwndbg-dev")
sys.exit(1)
# This tells tests/utils.py where to find the gdbinit.py file when used by various tests
os.environ["GDB_INIT_PATH"] = gdbinit_path
ensureZigPath()
makeBinaries()
tests: list[str] = getTestsList(args.collect_only, args.test_name_filter)

@ -1,12 +1,20 @@
from __future__ import annotations
import codecs
import os
import re
import subprocess
gdb_init_path = os.environ.get("GDB_INIT_PATH", "../../gdbinit.py")
def run_gdb_with_script(
binary="", core="", stdin_input=None, pybefore=None, pyafter=None, timeout=None
binary="",
core="",
stdin_input=None,
pybefore=None,
pyafter=None,
timeout=None,
):
"""
Runs GDB with given commands launched before and after loading of gdbinit.py
@ -20,7 +28,7 @@ def run_gdb_with_script(
for cmd in pybefore:
command += ["--eval-command", cmd]
command += ["--command", "../../gdbinit.py"]
command += ["--command", gdb_init_path]
if binary:
command += [binary]

Loading…
Cancel
Save