[gdb/testsuite] Fix gdb.dap/type_check.exp with older python
authorTom de Vries <tdevries@suse.de>
Tue, 13 Jun 2023 10:21:45 +0000 (12:21 +0200)
committerTom de Vries <tdevries@suse.de>
Tue, 13 Jun 2023 10:21:45 +0000 (12:21 +0200)
On openSUSE Leap 15.4 with system python 3.6, I run into:
...
(gdb) python check_everything()^M
(gdb) FAIL: gdb.dap/type_check.exp: type checker
...

In check_everything, the hasattr test fails silently:
...
def check_everything():
    # Older versions of Python can't really implement this.
    if hasattr(typing, "get_origin"):
...
and that makes the gdb_test in the test-case fail.

Fix this by emitting UNSUPPORTED instead in check_everything, and detecting
this in the test-case.

Tested on x86_64-linux.

gdb/testsuite/gdb.dap/type_check.exp
gdb/testsuite/gdb.dap/type_check.py

index 346b4ba75b11d0ab4e1eddcbd4a59b8285d172b6..441588e5b1e381dbcfac8c3a164c9abf77ee2f03 100644 (file)
@@ -26,4 +26,11 @@ set remote_python_file \
     [gdb_remote_download host ${srcdir}/${subdir}/${gdb_test_file_name}.py]
 gdb_test_no_output "source ${remote_python_file}" "load python file"
 
-gdb_test "python check_everything()" OK "type checker"
+gdb_test_multiple "python check_everything()" "type checker" {
+    -re -wrap "OK" {
+       pass $gdb_test_name
+    }
+    -re -wrap "UNSUPPORTED" {
+       unsupported $gdb_test_name
+    }
+}
index 1fdb595f3c636240e92ffcbc86632215d3245011..ec4982c2932a1ae6ccd78f77e3541ee410d3ef89 100644 (file)
@@ -94,3 +94,5 @@ def check_everything():
         check_map()
         check_opt()
         print("OK")
+    else:
+        print("UNSUPPORTED")