[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.
This commit is contained in:
Tom de Vries
2025-08-17 08:32:13 +02:00
parent 82f3f381fb
commit 3f7c685f26
6 changed files with 84 additions and 41 deletions

View 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"

View 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

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

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

View 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
if { ![is_remote host] } {
with_ansi_styling_terminal {
# Start with a fresh gdb.
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
# This enables 256 colors support and disables colors approximation.
setenv TERM xterm-256color
setenv COLORTERM truecolor
gdb_install_guile_utils
gdb_install_guile_module
# Start with a fresh gdb.
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
# We use "." here instead of ":" so that this works on win32 too.
set escaped_directory [string_to_regexp "$srcdir/$subdir"]
gdb_install_guile_utils
gdb_install_guile_module
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"
# We use "." here instead of ":" so that this works on win32 too.
set escaped_directory [string_to_regexp "$srcdir/$subdir"]
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"
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"
}
}
}
}

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