python: Add tests for trying to use an invalid Inferior object
authorSimon Marchi <simon.marchi@ericsson.com>
Wed, 12 Sep 2018 22:27:57 +0000 (18:27 -0400)
committerSimon Marchi <simon.marchi@ericsson.com>
Wed, 12 Sep 2018 22:27:57 +0000 (18:27 -0400)
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
gdb/testsuite/gdb.python/py-inferior.exp

index db5369de6516eee69ec9a6dffe2975b4db415674..949f1ae210a1c7450023bc6adb7f27aaf7eb5810 100644 (file)
@@ -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.
index a943d5f214e99c67851f6b5d82169404e658ce76..055dd87c6d84544f3f66e5d6d0dad875929c2620 100644 (file)
@@ -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()
This page took 0.034205 seconds and 4 git commands to generate.