From f8831c10debea095db177c6d65c1b0e50434227e Mon Sep 17 00:00:00 2001 From: Robert Scott Date: Tue, 26 Jan 2021 20:41:39 +0000 Subject: [PATCH] python3.tests: add cpython-gdb test --- .../development/interpreters/python/tests.nix | 18 ++++++++++----- .../python/tests/test_cpython_gdb/default.nix | 22 +++++++++++++++++++ 2 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 pkgs/development/interpreters/python/tests/test_cpython_gdb/default.nix diff --git a/pkgs/development/interpreters/python/tests.nix b/pkgs/development/interpreters/python/tests.nix index 872123338f8c..764ab29e919b 100644 --- a/pkgs/development/interpreters/python/tests.nix +++ b/pkgs/development/interpreters/python/tests.nix @@ -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 diff --git a/pkgs/development/interpreters/python/tests/test_cpython_gdb/default.nix b/pkgs/development/interpreters/python/tests/test_cpython_gdb/default.nix new file mode 100644 index 000000000000..0254d843a4cf --- /dev/null +++ b/pkgs/development/interpreters/python/tests/test_cpython_gdb/default.nix @@ -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 +''