python3.tests: add cpython-gdb test

This commit is contained in:
Robert Scott 2021-01-26 20:41:39 +00:00
parent 049444dc6b
commit f8831c10de
2 changed files with 34 additions and 6 deletions

View File

@ -94,12 +94,18 @@ let
# Integration tests involving the package set.
# All PyPy package builds are broken at the moment
integrationTests = lib.optionalAttrs (python.pythonAtLeast "3.7" && (!python.isPyPy)) rec {
# Before the addition of NIX_PYTHONPREFIX mypy was broken with typed packages
nix-pythonprefix-mypy = callPackage ./tests/test_nix_pythonprefix {
interpreter = python;
};
};
integrationTests = lib.optionalAttrs (!python.isPyPy) (
lib.optionalAttrs (python.isPy3k && !stdenv.isDarwin) { # darwin has no split-debug
cpython-gdb = callPackage ./tests/test_cpython_gdb {
interpreter = python;
};
} // lib.optionalAttrs (python.pythonAtLeast "3.7") rec {
# Before the addition of NIX_PYTHONPREFIX mypy was broken with typed packages
nix-pythonprefix-mypy = callPackage ./tests/test_nix_pythonprefix {
interpreter = python;
};
}
);
# Tests to ensure overriding works as expected.
overrideTests = let

View File

@ -0,0 +1,22 @@
{ interpreter, lib, gdb, writeText, runCommand }:
let
crashme-py = writeText "crashme.py" ''
import ctypes
def sentinel_foo_bar():
ctypes.memset(0, 1, 1)
sentinel_foo_bar()
'';
in runCommand "python-gdb" {} ''
# test that gdb is able to recover the python stack frame of this segfault
${gdb}/bin/gdb -batch -ex 'set debug-file-directory ${interpreter.debug}/lib/debug' \
-ex 'source ${interpreter}/share/gdb/libpython.py' \
-ex r \
-ex py-bt \
--args ${interpreter}/bin/python ${crashme-py} | grep 'in sentinel_foo_bar' > /dev/null
# success.
touch $out
''