aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2018-09-12 18:27:57 -0400
committerSimon Marchi <simon.marchi@ericsson.com>2018-09-12 18:27:57 -0400
commit4aa8e6c2387e796649279c2190cd499b579d028c (patch)
tree334b82d10a44ba8b1c7d7b627a1330a1c94390c9 /gdb
parent3c025cfe5efc44eb4dfb03b53dca28e75096dd1e (diff)
downloadgdb-4aa8e6c2387e796649279c2190cd499b579d028c.zip
gdb-4aa8e6c2387e796649279c2190cd499b579d028c.tar.gz
gdb-4aa8e6c2387e796649279c2190cd499b579d028c.tar.bz2
python: Add tests for trying to use an invalid Inferior object
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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.python/py-inferior.exp13
2 files changed, 18 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index db5369d..949f1ae 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 a943d5f..055dd87 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()