public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@ericsson.com>
Subject: [pushed] python: Add tests for trying to use an invalid Inferior object
Date: Wed, 12 Sep 2018 22:39:00 -0000	[thread overview]
Message-ID: <20180912223840.6141-1-simon.marchi@ericsson.com> (raw)

This patch adds tests for trying to use property or methods on a
gdb.Inferior object that represents an inferior that does not exist
anymore.  We expect an exception to be thrown.

gdb/testsuite/ChangeLog:

	* gdb.python/py-inferior.exp: Test using an invalid gdb.Inferior
	object.
---
 gdb/testsuite/ChangeLog                  |  5 +++++
 gdb/testsuite/gdb.python/py-inferior.exp | 13 +++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index db5369de651..949f1ae210a 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-09-12  Simon Marchi  <simon.marchi@ericsson.com>
+
+	* gdb.python/py-inferior.exp: Test using an invalid gdb.Inferior
+	object.
+
 2018-09-12  Alan Hayward  <alan.hayward@arm.com>
 
 	* lib/gdb.exp (gdb_can_simple_compile): Add proc.
diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp
index a943d5f214e..055dd87c6d8 100644
--- a/gdb/testsuite/gdb.python/py-inferior.exp
+++ b/gdb/testsuite/gdb.python/py-inferior.exp
@@ -253,6 +253,19 @@ with_test_prefix "is_valid" {
 
     gdb_test "python print (my_inferior_count)" "1" \
 	"test inferior-deleted event handler"
+
+    # Test that other properties and methods handle the removed inferior
+    # correctly.
+    gdb_test "python print (inf_list\[1\].num)" \
+	"RuntimeError: Inferior no longer exists.*"
+    gdb_test "python print (inf_list\[1\].pid)" \
+	"RuntimeError: Inferior no longer exists.*"
+    gdb_test "python print (inf_list\[1\].was_attached)" \
+	"RuntimeError: Inferior no longer exists.*"
+    gdb_test "python print (inf_list\[1\].threads ())" \
+	"RuntimeError: Inferior no longer exists.*"
+    gdb_test "python print (inf_list\[1\].thread_from_thread_handle (1))" \
+	"RuntimeError: Inferior no longer exists.*"
 }
 
 # Test gdb.selected_inferior()
-- 
2.19.0

                 reply	other threads:[~2018-09-12 22:39 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=20180912223840.6141-1-simon.marchi@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).