From: Tom de Vries Date: Sun, 17 Aug 2025 06:32:13 +0000 (+0200) Subject: [gdb/testsuite] Handle remote host in some test-cases X-Git-Tag: gdb-17-branchpoint~277 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3f7c685f26df75ee3822a3629b2794deafdf881f;p=thirdparty%2Fbinutils-gdb.git [gdb/testsuite] Handle remote host in some test-cases 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. --- diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp index 01e3cc12bd3..50fae7cd55f 100644 --- a/gdb/testsuite/gdb.base/default.exp +++ b/gdb/testsuite/gdb.base/default.exp @@ -759,7 +759,6 @@ set show_conv_list \ {$_probe_arg10 = } \ {$_probe_arg11 = } \ {$_cimag = } \ - {$_colorsupport = "monochrome"} \ {$_creal = } \ {$_isvoid = } \ {$_shell = } \ @@ -788,10 +787,40 @@ if [allow_python_tests] { {$_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" diff --git a/gdb/testsuite/gdb.base/readline-ask.exp b/gdb/testsuite/gdb.base/readline-ask.exp index 3f98e133dd3..2948970b706 100644 --- a/gdb/testsuite/gdb.base/readline-ask.exp +++ b/gdb/testsuite/gdb.base/readline-ask.exp @@ -13,6 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +require {!is_remote host} + standard_testfile .c set inputrc ${srcdir}/${subdir}/${testfile}.inputrc diff --git a/gdb/testsuite/gdb.base/readline.exp b/gdb/testsuite/gdb.base/readline.exp index 198d686df06..9b87790f62e 100644 --- a/gdb/testsuite/gdb.base/readline.exp +++ b/gdb/testsuite/gdb.base/readline.exp @@ -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. diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp index a6c18d34269..6b1b08e9d5e 100644 --- a/gdb/testsuite/gdb.base/style.exp +++ b/gdb/testsuite/gdb.base/style.exp @@ -13,6 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +require {!is_remote host} + load_lib gdb-python.exp # Test CLI output styling. diff --git a/gdb/testsuite/gdb.guile/scm-parameter.exp b/gdb/testsuite/gdb.guile/scm-parameter.exp index e35428a8495..0ee11e653e3 100644 --- a/gdb/testsuite/gdb.guile/scm-parameter.exp +++ b/gdb/testsuite/gdb.guile/scm-parameter.exp @@ -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))" "= #" "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))" "= #" "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))" "= #" "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))" "= #" "color parameter value (255)" + gdb_test "set print test-color-param 256" "integer 256 out of range.*" "set invalid color parameter" + } } } } diff --git a/gdb/testsuite/gdb.python/py-parameter.exp b/gdb/testsuite/gdb.python/py-parameter.exp index 214c570724a..e676925af44 100644 --- a/gdb/testsuite/gdb.python/py-parameter.exp +++ b/gdb/testsuite/gdb.python/py-parameter.exp @@ -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.