mirror of https://github.com/pwndbg/pwndbg
Fix codecov (#1792)
* Fix coverage combine toml issue This commit should fix this issue: ``` Run coverage combine coverage combine coverage xml shell: /usr/bin/bash -e {0} Can't read 'pyproject.toml' without TOML support. Install with [toml] extra Error: Process completed with exit code 1. ``` * setup.sh: cleanup the --user flag since we use venv now Cleans up the --user flag from setup.sh since it is unused after we changed setup.sh to install Python dependencies in a virtual environment * Remove --user flag from CI workflows * Fix codecov problem We need to run the python `coverage` library to collect coverage. However, gdb was failing to find it. Recently, pwndbg moved to using venvs. When pwndbg is initialized it setups the venv "manually", that is, no "source .venv/bin/activate" is needed. When we run gdb tests, we pass the `gdbinit.py` of pwndbg as a command to gdb to be executed like this: `gdb --silent --nx --nh -ex 'py import coverage;coverage.process_startup()' --command PATH_TO_gdbinit.py` The problem is that *order* matters. This means that *first* coverage is imported (by `-ex py ...`) and only *then* the init script is executed. When `coverage` is first imported, it's library search path only looks in system libraries of python, and not the venv that gdbinit.py would load. So we would try to import an old version of coverage and fail. One solution would be to move around the commands, but this would be an ugly hack IMHO. **Instead**, we should just tell gdb that this is an **init** command that has to be executed before other commands. Previously, the order did not matter. All of pwndbg's dependencies were installed directly as system libraries to python. So the library search path was the same before and after loading `gdbinit.py`. --------- Co-authored-by: disconnect3d <dominik.b.czarnota@gmail.com> Co-authored-by: intrigus <abc123zeus@live.de>
This commit is contained in:
parent
de4acb2f40
commit
7d9d2dc1de
|
@ -19,8 +19,8 @@ jobs:
|
|||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
./setup.sh --user
|
||||
./setup-dev.sh --user
|
||||
./setup.sh
|
||||
./setup-dev.sh
|
||||
|
||||
- name: Run linters
|
||||
run: |
|
||||
|
|
|
@ -19,18 +19,17 @@ jobs:
|
|||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
./setup.sh --user
|
||||
./setup-dev.sh --user
|
||||
pip install --user coveralls
|
||||
./setup.sh
|
||||
./setup-dev.sh
|
||||
|
||||
- name: Python version info
|
||||
run: |
|
||||
echo 'GDB py:'
|
||||
gdb --batch --quiet --nx --nh --ex 'py import sys; print(sys.version)'
|
||||
echo 'Installed py:'
|
||||
python -V
|
||||
./.venv/bin/python -V
|
||||
echo 'Installed packages:'
|
||||
python -m pip freeze
|
||||
./.venv/bin/python -m pip freeze
|
||||
|
||||
# We set `kernel.yama.ptrace_scope=0` for `attachp` command tests
|
||||
- name: Run tests
|
||||
|
@ -42,8 +41,8 @@ jobs:
|
|||
- name: Process coverage data
|
||||
if: matrix.os == 'ubuntu-22.04'
|
||||
run: |
|
||||
coverage combine
|
||||
coverage xml
|
||||
./.venv/bin/coverage combine
|
||||
./.venv/bin/coverage xml
|
||||
|
||||
- name: "Upload coverage to Codecov"
|
||||
if: matrix.os == 'ubuntu-22.04'
|
||||
|
@ -63,8 +62,8 @@ jobs:
|
|||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
./setup.sh --user
|
||||
./setup-dev.sh --user
|
||||
./setup.sh
|
||||
./setup-dev.sh
|
||||
mkdir .cov
|
||||
|
||||
- name: Set up cache for QEMU images
|
||||
|
@ -92,8 +91,8 @@ jobs:
|
|||
|
||||
- name: Process coverage data
|
||||
run: |
|
||||
coverage combine
|
||||
coverage xml
|
||||
./.venv/bin/coverage combine
|
||||
./.venv/bin/coverage xml
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v3
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
black==22.8.0; python_version < '3.7'
|
||||
black==23.3.0; python_version >= '3.7'
|
||||
coverage==6.2; python_version < '3.7'
|
||||
coverage==7.2.6; python_version >= '3.7'
|
||||
coverage[toml]==6.2; python_version < '3.7'
|
||||
coverage[toml]==7.2.6; python_version >= '3.7'
|
||||
tomli==1.2.3 ; python_version < '3.7'
|
||||
tomli==2.0.1 ; python_version >= '3.7'
|
||||
isort==5.10.1; python_version <= '3.7'
|
||||
isort==5.12.0; python_version > '3.7'
|
||||
mypy==1.3.0; python_version >= '3.7'
|
||||
pytest==7.0.1; python_version < '3.7'
|
||||
pytest==7.3.1; python_version >= '3.7'
|
||||
pytest-cov==4.0.0 ; python_version < '3.7'
|
||||
pytest-cov==4.1.0 ; python_version >= '3.7'
|
||||
rich==12.6.0; python_version < '3.7'
|
||||
rich==13.3.5; python_version >= '3.7'
|
||||
ruff==0.0.270; python_version >= '3.7'
|
||||
|
|
7
setup.sh
7
setup.sh
|
@ -69,21 +69,16 @@ install_pacman() {
|
|||
}
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 [--update] [--user]"
|
||||
echo "Usage: $0 [--update]"
|
||||
echo " --update: Install/update dependencies without checking ~/.gdbinit"
|
||||
echo " --user: Install pip dependencies to the user's home directory"
|
||||
}
|
||||
|
||||
UPDATE_MODE=
|
||||
USER_MODE=
|
||||
for arg in "$@"; do
|
||||
case $arg in
|
||||
--update)
|
||||
UPDATE_MODE=1
|
||||
;;
|
||||
--user)
|
||||
USER_MODE=1
|
||||
;;
|
||||
-h | --help)
|
||||
set +x
|
||||
usage
|
||||
|
|
|
@ -101,7 +101,7 @@ run_gdb() {
|
|||
|
||||
# NOTE: We run tests under GDB sessions and because of some cleanup/tests dependencies problems
|
||||
# we decided to run each test in a separate GDB session
|
||||
gdb_args=(--command $GDB_INIT_PATH --command pytests_collect.py)
|
||||
gdb_args=(--init-command $GDB_INIT_PATH --command pytests_collect.py)
|
||||
TESTS_COLLECT_OUTPUT=$(run_gdb "${gdb_args[@]}")
|
||||
|
||||
if [ $? -eq 1 ]; then
|
||||
|
@ -117,7 +117,7 @@ TESTS_LIST=($(echo -E "$TESTS_COLLECT_OUTPUT" | grep -o "tests/.*::.*" | grep "$
|
|||
run_test() {
|
||||
test_case="$1"
|
||||
|
||||
gdb_args=(--command $GDB_INIT_PATH --command pytests_launcher.py)
|
||||
gdb_args=(--init-command $GDB_INIT_PATH --command pytests_launcher.py)
|
||||
if [ ${RUN_CODECOV} -ne 0 ]; then
|
||||
gdb_args=(-ex 'py import coverage;coverage.process_startup()' "${gdb_args[@]}")
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue