]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Handle missing curses in gdb.python/py-missing-debug.exp
authorTom de Vries <tdevries@suse.de>
Sun, 8 Sep 2024 05:46:09 +0000 (07:46 +0200)
committerTom de Vries <tdevries@suse.de>
Sun, 8 Sep 2024 05:46:09 +0000 (07:46 +0200)
On a system with python 3.6, module gdb.missing_debug imports module curses,
so when running test-case gdb.python/py-missing-debug.exp on a system without
that module installed, we run into:
...
(gdb) source py-missing-debug.py^M
Python Exception <class 'ImportError'>: Module 'curses' is not installed.^M
Use:^M
  sudo zypper install python36-curses^M
to install it.^M
Error occurred in Python: Module 'curses' is not installed.^M
Use:^M
  sudo zypper install python36-curses^M
to install it.^M
(gdb) FAIL: gdb.python/py-missing-debug.exp: source python script
...

Fix this by issuing UNSUPPORTED instead, and bailing out.

Tested on x86_64-linux.

Approved-by: Kevin Buettner <kevinb@redhat.com>
PR testsuite/31576
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31576

gdb/testsuite/gdb.python/py-missing-debug.exp

index dfc0a467b2ad3aa986fa60cc13f7fc40cf736f62..9d853d3a311347ea59b9fb815bb2c6fe864417c8 100644 (file)
@@ -58,8 +58,21 @@ with_test_prefix "initial checks" {
 }
 
 # Load the Python script into GDB.
-gdb_test "source $remote_python_file" "^Success" \
-    "source python script"
+set python_script_loaded 0
+set re_no_curses [string_to_regexp "Module 'curses' is not installed."]
+gdb_test_multiple "source $remote_python_file" "source python script" {
+    -re -wrap $re_no_curses.* {
+       unsupported $gdb_test_name
+    }
+    -re -wrap "^Success" {
+       set python_script_loaded 1
+       pass $gdb_test_name
+    }
+}
+
+if { ! $python_script_loaded } {
+    return
+}
 
 # Setup the separate debug info directory.  This isn't actually needed until
 # some of the later tests, but might as well get this done now.