fix relative imports in tests (#3163)

* fix relative imports
pull/3160/head^2
patryk4815 5 months ago committed by GitHub
parent b27b5bf2c2
commit 7e7c47f209
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -5,12 +5,12 @@
# E.g. the binary could reference source code on the host system
# this is a problem because inside docker we won't have access to
# the host system
tests/**/binaries/*.o
tests/**/binaries/*.out
tests/**/binaries/gosample.x*
tests/**/binaries/div_zero_binary/core
tests/**/binaries/div_zero_binary/binary
!tests/**/binaries/*.go
tests/binaries/**/*.o
tests/binaries/**/*.out
tests/binaries/**/gosample.x*
tests/binaries/**/div_zero_binary/core
tests/binaries/**/div_zero_binary/binary
!tests/binaries/**/*.go
# ignore QEMU test images (could also be tainted)
tests/library/qemu-*/kimages
tests/library/qemu_system/kimages

@ -36,7 +36,7 @@ class GDBTestHost(TestHost):
env = os.environ if env is None else env
# Prepare the GDB command line.
gdb_args = ["-ex", f"py import sys,os; sys.path.append(os.getcwd()); import {target}"]
gdb_args = ["-ex", f"py import sys,os; sys.path.insert(0, os.getcwd()); import {target}"]
return subprocess.run(
[str(self._gdb_path), "--silent", "--nx"]

@ -146,15 +146,15 @@ run_gdb() {
echo "$GDB --nx ${gdb_load_pwndbg[@]} -ex \"set exception-debugger on\" -ex \"file ${TESTING_KERNEL_IMAGES_DIR}/vmlinux-${kernel_type}-${kernel_version}-${arch}\" -ex \"target remote :${GDB_PORT}\""
read -p "Press enter to continue"
else
$UV_RUN_TEST $GDB --silent --nx "${gdb_load_pwndbg[@]}" \
-ex "set exception-verbose on" "$@" -ex "quit" 2> /dev/null
(cd $PWNDBG_ABS_PATH && $UV_RUN_TEST $GDB --silent --nx "${gdb_load_pwndbg[@]}" \
-ex "set exception-verbose on" "$@" -ex "quit" 2> /dev/null)
fi
return $?
}
# 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=("-ex" "py import sys,os; sys.path.append(os.getcwd()); import tests.host.gdb.pytests_collect")
gdb_args=("-ex" "py import sys,os; sys.path.insert(0, os.getcwd()); import tests.host.gdb.pytests_collect")
TESTS_COLLECT_OUTPUT=$(TESTS_PATH="$ROOT_DIR/tests/library/qemu_system/tests/" run_gdb "x86_64" 0 "${gdb_args[@]}")
if [ $? -eq 1 ]; then
@ -187,7 +187,7 @@ run_test() {
local should_drop_to_pdb=$5
gdb_connect_qemu=(-ex "file ${TESTING_KERNEL_IMAGES_DIR}/vmlinux-${kernel_type}-${kernel_version}-${arch}" -ex "target remote :${GDB_PORT}")
gdb_args=("${gdb_connect_qemu[@]}" "-ex" "py import sys,os; sys.path.append(os.getcwd()); import tests.host.gdb.pytests_launcher")
gdb_args=("${gdb_connect_qemu[@]}" "-ex" "py import sys,os; sys.path.insert(0, os.getcwd()); import tests.host.gdb.pytests_launcher")
if [ ${RUN_CODECOV} -ne 0 ]; then
gdb_args=(-ex 'py import coverage;coverage.process_startup()' "${gdb_args[@]}")
fi

Loading…
Cancel
Save