diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 73cc225b1..ea2ac90ee 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -37,7 +37,7 @@ jobs: run: | mkdir .cov sudo sysctl -w kernel.yama.ptrace_scope=0 - PWNDBG_GITHUB_ACTIONS_TEST_RUN=1 ./tests.sh + PWNDBG_GITHUB_ACTIONS_TEST_RUN=1 ./tests.sh --cov - name: Process coverage data if: matrix.os == 'ubuntu-22.04' diff --git a/tests/gdb-tests/tests.sh b/tests/gdb-tests/tests.sh index 25ca86af5..31ff68986 100755 --- a/tests/gdb-tests/tests.sh +++ b/tests/gdb-tests/tests.sh @@ -5,18 +5,20 @@ GDB_INIT_PATH="$ROOT_DIR/gdbinit.py" COVERAGERC_PATH="$ROOT_DIR/pyproject.toml" help_and_exit() { - echo "Usage: ./tests.sh [-p|--pdb] []" + echo "Usage: ./tests.sh [-p|--pdb] [-c|--cov] []" echo " -p, --pdb enable pdb (Python debugger) post mortem debugger on failed tests" + echo " -c, --cov enable codecov" echo " run only tests that match the regex" exit 1 } -if [[ $# -gt 2 ]]; then +if [[ $# -gt 3 ]]; then help_and_exit fi USE_PDB=0 TEST_NAME_FILTER="" +RUN_CODECOV=0 while [[ $# -gt 0 ]]; do case $1 in @@ -25,6 +27,11 @@ while [[ $# -gt 0 ]]; do echo "Will run tests with Python debugger" shift ;; + -c | --cov) + echo "Will run codecov" + RUN_CODECOV=1 + shift + ;; -h | --help) help_and_exit ;; @@ -67,7 +74,10 @@ tests_passed_or_skipped=0 tests_failed=0 for test_case in ${TESTS_LIST}; do - gdb_args=(-ex 'py import coverage;coverage.process_startup()' --command $GDB_INIT_PATH --command pytests_launcher.py) + gdb_args=(--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 SRC_DIR=$ROOT_DIR \ COVERAGE_FILE=$ROOT_DIR/.cov/coverage \ COVERAGE_PROCESS_START=$COVERAGERC_PATH \