Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [pushed] [gdb/testsuite] Improve gdb.python/remove-readline-finder.exp
Date: Wed,  5 Aug 2026 15:08:19 +0200	[thread overview]
Message-ID: <20260805130819.1531072-1-tdevries@suse.de> (raw)

I came across test-case gdb.python/remove-readline-finder.exp.

It checks that a "python import readline" command fails.

Extend the test-case with also checking that the readline module is not
present in the sys.modules dict.

While we're at it, modernize a regexp using multi_line.

Tested on x86_64-linux (using make-check-all.sh) and aarch64-linux.
---
 .../gdb.python/remove-readline-finder.exp      | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.python/remove-readline-finder.exp b/gdb/testsuite/gdb.python/remove-readline-finder.exp
index 362e90e6b7c..325e9710e28 100644
--- a/gdb/testsuite/gdb.python/remove-readline-finder.exp
+++ b/gdb/testsuite/gdb.python/remove-readline-finder.exp
@@ -23,5 +23,21 @@ standard_testfile
 
 clean_restart
 
+gdb_test_no_output "py import sys"
+
+# Check that readline is not imported.
+with_test_prefix initial {
+    gdb_test "py print (sys.modules.get('readline'))" \
+       "None"
+}
+
+# Try to import readline, and check that it fails.
+set re_msg "readline module disabled under GDB"
 gdb_test "py import readline" \
-  "Python Exception <class 'ImportError'>: readline module disabled under GDB\r\n.*"
+    [multi_line \
+	"Python Exception <class 'ImportError'>: $re_msg" \
+	"Error occurred in Python: $re_msg"]
+
+# Check that readline is still not imported.
+gdb_test "py print (sys.modules.get('readline'))" \
+    "None"

base-commit: cd4e3876afb11e07fb7f3ccc10a87e3b990074eb
-- 
2.51.0


                 reply	other threads:[~2026-08-05 13:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260805130819.1531072-1-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox