]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Handle remote host in some test-cases
authorTom de Vries <tdevries@suse.de>
Sun, 17 Aug 2025 06:32:13 +0000 (08:32 +0200)
committerTom de Vries <tdevries@suse.de>
Sun, 17 Aug 2025 06:32:13 +0000 (08:32 +0200)
I ran test-case gdb.base/default.exp with make-check-all.sh, and noticed a
FAIL with host/target board local-remote-host-native:
...
FAIL: $exp: show convenience ($_colorsupport = "monochrome" not found)
...

The problem is that part of the test-case relies on "setenv TERM dumb", and
setenv, which is a tcl command (which runs on build), only has effect in gdb
(which runs on host), if build == host, in other words, local host.

I grepped for test-cases using setenv, and ran them with the host/target
board, and fixed the FAILs I saw.

All FAILs have the same cause as I described above, except for
proc test_data_directory in gdb.python/py-parameter.exp, which handles files
assuming local host.  I chose to leave it that way, and bail out but add a
comment.

Implementationwise, the change to test-case gdb.base/default.exp is the most
intrusive: it replaces a use of proc gdb_test_list_exact with a use of proc
gdb_get_lines_no_pass, because it allows specifying a regexp match.

In the process, I found out gdb_test_list_exact has a bug, filed as PR33038.

Because of this bug, I had to add matching of convenience variable $_tbl.

Tested on x86_64-linux.

gdb/testsuite/gdb.base/default.exp
gdb/testsuite/gdb.base/readline-ask.exp
gdb/testsuite/gdb.base/readline.exp
gdb/testsuite/gdb.base/style.exp
gdb/testsuite/gdb.guile/scm-parameter.exp
gdb/testsuite/gdb.python/py-parameter.exp

index 01e3cc12bd3ef5dfc82f6d28717f8db34b734366..50fae7cd55ff36805039434571aee3f1351dfb14 100644 (file)
@@ -759,7 +759,6 @@ set show_conv_list \
        {$_probe_arg10 = <error: No frame selected>} \
        {$_probe_arg11 = <error: No frame selected>} \
        {$_cimag = <internal function _cimag>} \
-       {$_colorsupport = "monochrome"} \
        {$_creal = <internal function _creal>} \
        {$_isvoid = <internal function _isvoid>} \
        {$_shell = <internal function _shell>} \
@@ -788,10 +787,40 @@ if [allow_python_tests] {
            {$_any_caller_matches = <internal function _any_caller_matches>} \
        }
 }
-gdb_test_list_exact "show convenience" "show convenience" \
-    "\[^\r\n\]+\[\r\n\]+" \
-    "\[^\r\n\]+" \
-    $show_conv_list
+
+set lines [gdb_get_lines_no_pass "show convenience"]
+set matches 0
+set all_found 1
+foreach s $show_conv_list {
+    if { ![regexp (^|\r\n)[string_to_regexp $s](\r\n|$) $lines] } {
+       verbose -log "didn't match: '$s'"
+       set all_found 0
+       break
+    }
+    incr matches
+}
+
+set re_var [string_to_regexp {$_colorsupport}]
+if { [is_remote host] } {
+    set re_val {[^\r\n]+}
+} else {
+    set re_val [string_to_regexp {"monochrome"}]
+}
+if { [regexp "$re_var = $re_val" $lines] } {
+    incr matches
+} else {
+    set all_found 0
+}
+
+if { [regexp [string_to_regexp {$_tlb = void}] $lines] } {
+    incr matches
+} else {
+    # Convenience variable _tlb is added only if support for windows targets
+    # is enabled.  Don't complain if it's missing.
+}
+
+gdb_assert { $all_found && $matches == [count_newlines $lines] } \
+    "show convenience"
 
 #test show directories
 gdb_test "show directories" "Source directories searched: .cdir\[:;\].cwd"
index 3f98e133dd3cd317798621d0e6d59f9ab20c0738..2948970b7061362526c256fa0d6659bd56ce33b3 100644 (file)
@@ -13,6 +13,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+require {!is_remote host}
+
 standard_testfile .c
 set inputrc ${srcdir}/${subdir}/${testfile}.inputrc
 
index 198d686df06ca1537cec4933e70161eee3aafcb3..9b87790f62e3f2456bb9208a774e8246f53d5ce3 100644 (file)
@@ -21,6 +21,8 @@
 # Tests for readline operations.
 #
 
+require {!is_remote host}
+
 # This function is used to test operate-and-get-next.
 # NAME is the name of the test.
 # ARGS is a list of alternating commands and expected results.
index a6c18d34269353decd03a25301ac436d6c38b76d..6b1b08e9d5effc0fee51e533380dce0412c6c3da 100644 (file)
@@ -13,6 +13,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+require {!is_remote host}
+
 load_lib gdb-python.exp
 
 # Test CLI output styling.
index e35428a8495281308ed8cd06b1fe5670bc531ed0..0ee11e653e320912e10085536d6d181b415c3b0e 100644 (file)
@@ -565,47 +565,50 @@ rename scm_param_test_maybe_no_output ""
 
 # Test a color parameter.
 
-with_ansi_styling_terminal {
-    # This enables 256 colors support and disables colors approximation.
-    setenv TERM xterm-256color
-    setenv COLORTERM truecolor
-
-    # Start with a fresh gdb.
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-
-    gdb_install_guile_utils
-    gdb_install_guile_module
-
-    # We use "." here instead of ":" so that this works on win32 too.
-    set escaped_directory [string_to_regexp "$srcdir/$subdir"]
-
-    gdb_test_multiline "color gdb parameter" \
-       "guile" "" \
-       "(define test-color-param" "" \
-       "  (make-parameter \"print test-color-param\"" "" \
-       "   #:command-class COMMAND_DATA" "" \
-       "   #:parameter-type PARAM_COLOR" "" \
-       "   #:doc \"When set, test param does something useful. When disabled, does nothing.\"" "" \
-       "   #:show-doc \"Show the state of the test-color-param.\"" "" \
-       "   #:set-doc \"Set the state of the test-color-param.\"" "" \
-       "   #:show-func (lambda (self value)" "" \
-       "      (format #f \"The state of the test-color-param is ~a.\" value))" "" \
-       "   #:initial-value (make-color \"green\")))" "" \
-       "(register-parameter! test-color-param)" "" \
-       "end"
-
-    with_test_prefix "test-color-param" {
-       with_test_prefix "initial-value" {
-           gdb_test "guile (print (parameter-value test-color-param))" "= #<gdb:color green COLORSPACE_ANSI_8COLOR>" "color parameter value (green)"
-           gdb_test "show print test-color-param" "The state of the test-color-param is green." "show initial value"
-           gdb_test_no_output "set print test-color-param 255"
-       }
-       with_test_prefix "new-value" {
-           gdb_test "show print test-color-param" "The state of the test-color-param is 255." "show new value"
-           gdb_test "guile (print (parameter-value test-color-param))" "= #<gdb:color 255 COLORSPACE_XTERM_256COLOR>" "color parameter value (255)"
-           gdb_test "set print test-color-param 256" "integer 256 out of range.*" "set invalid color parameter"
+if { ![is_remote host] } {
+    with_ansi_styling_terminal {
+
+       # This enables 256 colors support and disables colors approximation.
+       setenv TERM xterm-256color
+       setenv COLORTERM truecolor
+
+       # Start with a fresh gdb.
+       gdb_exit
+       gdb_start
+       gdb_reinitialize_dir $srcdir/$subdir
+
+       gdb_install_guile_utils
+       gdb_install_guile_module
+
+       # We use "." here instead of ":" so that this works on win32 too.
+       set escaped_directory [string_to_regexp "$srcdir/$subdir"]
+
+       gdb_test_multiline "color gdb parameter" \
+           "guile" "" \
+           "(define test-color-param" "" \
+           "  (make-parameter \"print test-color-param\"" "" \
+           "   #:command-class COMMAND_DATA" "" \
+           "   #:parameter-type PARAM_COLOR" "" \
+           "   #:doc \"When set, test param does something useful. When disabled, does nothing.\"" "" \
+           "   #:show-doc \"Show the state of the test-color-param.\"" "" \
+           "   #:set-doc \"Set the state of the test-color-param.\"" "" \
+           "   #:show-func (lambda (self value)" "" \
+           "      (format #f \"The state of the test-color-param is ~a.\" value))" "" \
+           "   #:initial-value (make-color \"green\")))" "" \
+           "(register-parameter! test-color-param)" "" \
+           "end"
+
+       with_test_prefix "test-color-param" {
+           with_test_prefix "initial-value" {
+               gdb_test "guile (print (parameter-value test-color-param))" "= #<gdb:color green COLORSPACE_ANSI_8COLOR>" "color parameter value (green)"
+               gdb_test "show print test-color-param" "The state of the test-color-param is green." "show initial value"
+               gdb_test_no_output "set print test-color-param 255"
+           }
+           with_test_prefix "new-value" {
+               gdb_test "show print test-color-param" "The state of the test-color-param is 255." "show new value"
+               gdb_test "guile (print (parameter-value test-color-param))" "= #<gdb:color 255 COLORSPACE_XTERM_256COLOR>" "color parameter value (255)"
+               gdb_test "set print test-color-param 256" "integer 256 out of range.*" "set invalid color parameter"
+           }
        }
     }
 }
index 214c570724aeda089962f3ee034e57b444288aac..e676925af445534e01f88bc7995ff0a9e096613e 100644 (file)
@@ -45,6 +45,9 @@ proc_with_prefix test_directories { } {
 }
 
 proc_with_prefix test_data_directory { } {
+    # Proc assumes local host.
+    require {!is_remote host}
+
     clean_restart
 
     # Check we can correctly read the data-directory parameter.  First,
@@ -187,6 +190,8 @@ proc_with_prefix test_enum_parameter { } {
 
 # Test an color parameter.
 proc_with_prefix test_color_parameter { } {
+    require {!is_remote host}
+
     global env
     with_ansi_styling_terminal {
        # This enables 256 colors support and disables colors approximation.