binutils-gdb/gdb/testsuite/gdb.python/py-charset.exp

51 lines
1.8 KiB
Plaintext
Raw Normal View History

# Copyright 2022 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
load_lib gdb-python.exp
gdb_exit
gdb_start
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
# Each test data has 4 parts:
# 1. The string used in 'show XXX-charset' command,
# 2. The string expected in the output of the command used in #1,
# 3. The string used is gdb.XXXX_charset() python function call,
# 4. A string that is a regexp appended to the result of #1, used to
# match the output of #3
foreach test_data { {host host host ""} \
{target target target ""} \
{target-wide "target wide" \
"target_wide" "(LE|BE)?"} } {
with_test_prefix "charset=[lindex $test_data 0]" {
set charset "unknown"
gdb_test_multiple "show [lindex $test_data 0]-charset" "" {
-re "The [lindex $test_data 1] character set is \"auto; currently (\[^\"\]*)\".*$gdb_prompt $" {
set charset $expect_out(1,string)
pass $gdb_test_name
}
-re "The [lindex $test_data 1] character set is \"(\[^\"\]*)\".*$gdb_prompt $" {
set charset $expect_out(1,string)
pass $gdb_test_name
}
}
set charset "${charset}[lindex $test_data 3]"
gdb_test "python print(gdb.[lindex $test_data 2]_charset())" \
"${charset}"
}
}