Home | History | Annotate | Line # | Download | only in gdb.python
      1 # Copyright 2022-2024 Free Software Foundation, Inc.
      2 
      3 # This program is free software; you can redistribute it and/or modify
      4 # it under the terms of the GNU General Public License as published by
      5 # the Free Software Foundation; either version 3 of the License, or
      6 # (at your option) any later version.
      7 #
      8 # This program is distributed in the hope that it will be useful,
      9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11 # GNU General Public License for more details.
     12 #
     13 # You should have received a copy of the GNU General Public License
     14 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15 
     16 load_lib gdb-python.exp
     17 
     18 require allow_python_tests
     19 
     20 gdb_exit
     21 gdb_start
     22 
     23 # Each test data has 4 parts:
     24 # 1. The string used in 'show XXX-charset' command,
     25 # 2. The string expected in the output of the command used in #1,
     26 # 3. The string used is gdb.XXXX_charset() python function call,
     27 # 4. A string that is a regexp appended to the result of #1, used to
     28 #    match the output of #3
     29 foreach test_data { {host host host ""} \
     30 			{target target target ""} \
     31 			{target-wide "target wide" \
     32 			     "target_wide" "(LE|BE)?"} } {
     33     with_test_prefix "charset=[lindex $test_data 0]" {
     34 	set charset "unknown"
     35 	gdb_test_multiple "show [lindex $test_data 0]-charset" "" {
     36 	    -re "The [lindex $test_data 1] character set is \"auto; currently (\[^\"\]*)\".*$gdb_prompt $" {
     37 		set charset $expect_out(1,string)
     38 		pass $gdb_test_name
     39 	    }
     40 	    -re "The [lindex $test_data 1] character set is \"(\[^\"\]*)\".*$gdb_prompt $" {
     41 		set charset $expect_out(1,string)
     42 		pass $gdb_test_name
     43 	    }
     44 	}
     45 	set charset "${charset}[lindex $test_data 3]"
     46 	gdb_test "python print(gdb.[lindex $test_data 2]_charset())" \
     47 	    "${charset}"
     48     }
     49 }
     50