public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [pushed] [gdb/testsuite] Fix gdb.dap/type_check.exp with older python
@ 2023-06-13 10:22 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2023-06-13 10:22 UTC (permalink / raw)
  To: gdb-patches

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 | 9 ++++++++-
 gdb/testsuite/gdb.dap/type_check.py  | 2 ++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.dap/type_check.exp b/gdb/testsuite/gdb.dap/type_check.exp
index 346b4ba75b1..441588e5b1e 100644
--- a/gdb/testsuite/gdb.dap/type_check.exp
+++ b/gdb/testsuite/gdb.dap/type_check.exp
@@ -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
+    }
+}
diff --git a/gdb/testsuite/gdb.dap/type_check.py b/gdb/testsuite/gdb.dap/type_check.py
index 1fdb595f3c6..ec4982c2932 100644
--- a/gdb/testsuite/gdb.dap/type_check.py
+++ b/gdb/testsuite/gdb.dap/type_check.py
@@ -94,3 +94,5 @@ def check_everything():
         check_map()
         check_opt()
         print("OK")
+    else:
+        print("UNSUPPORTED")

base-commit: bdde90c4cea27aacb0b98b4b1fa7289cb1a96168
-- 
2.35.3


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-13 10:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-13 10:22 [pushed] [gdb/testsuite] Fix gdb.dap/type_check.exp with older python Tom de Vries

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).