old-cross-binutils/gdb/testsuite/gdb.base/wchar.exp
Yao Qi 0fc0599720 Different outputs affected by hosts
We find the following fails in gdb test on mingw host.

FAIL: gdb.base/wchar.exp: print repeat
FAIL: gdb.base/wchar.exp: print repeat_p
FAIL: gdb.base/wchar.exp: print repeat (print null on)
FAIL: gdb.base/wchar.exp: print repeat (print elements 3)
FAIL: gdb.base/wchar.exp: print repeat_p (print elements 3)

print repeat^M
$7 = L"A", '¢' <repeats 21 times>, "B", '\000' <repeats 104 times>^M
(gdb) FAIL: gdb.base/wchar.exp: print repeat

the \242 is expected in the test but cent sign is displayed.

In valprint.c:print_wchar, wchar_printable is called to determine
whether a wchar is printable.  wchar_printable calls iswprint but
the iswprint's return value depends on LC_CTYPE setting of locale [1, 2].
The output may vary with different locale settings and OS.  IMO, '¢'
(cent sign) is a correct output on Windows.

[1] http://pubs.opengroup.org/onlinepubs/009604499/functions/iswprint.html
[2] http://msdn.microsoft.com/en-us/library/ewx8s4kw.aspx

This patch is set $cent to cent sign if the GDB is running on a
Windows host.

gdb/testsuite:

2014-06-17  Yao Qi  <yao@codesourcery.com>

	* gdb.base/wchar.exp: Set $cent to \u00A2 if "host-charset" is
	CP1252.
2014-06-17 19:35:32 +08:00

71 lines
2 KiB
Text

# Copyright 2011-2014 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/>.
standard_testfile .c
if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
return -1
}
set bp_location [gdb_get_line_number "START"]
if ![runto "wchar.c:$bp_location" ] then {
return -1
}
gdb_test "print narrow" "= 97 L'a'"
gdb_test "print single" "= 48879 L'\\\\xbeef'"
gdb_test "print simple" "= L\"facile\""
gdb_test "print difficile" "= L\"\\\\xdead\\\\xbeef\\\\xfeed\\\\xface\""
gdb_test "print simple\[2\]" "= 99 L'c'"
gdb_test "print difficile\[2\]" "= 65261 L'\\\\xfeed'"
set cent "\\\\242"
set test "show host-charset"
gdb_test_multiple $test $test {
-re "CP1252\".*\r\n$gdb_prompt $" {
# With Windows code page 1252 (Latin 1), the cent
# is printable.
set cent "\u00A2"
pass $test
}
-re "$gdb_prompt $" {
pass $test
}
}
gdb_test "print repeat" "= L\"A\", '$cent' <repeats 21 times>, \"B.*"
global hex
gdb_test "print repeat_p" \
"= $hex L\"A\", '$cent' <repeats 21 times>, \"B\""
gdb_test_no_output "set print null on"
gdb_test "print repeat" "= L\"A\", '$cent' <repeats 21 times>, \"B\"" \
"print repeat (print null on)"
gdb_test_no_output "set print elements 3"
gdb_test "print repeat" "= L\"A$cent$cent\"\.\.\." \
"print repeat (print elements 3)"
gdb_test "print repeat_p" "= $hex L\"A$cent$cent\"\.\.\." \
"print repeat_p (print elements 3)"