aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2023-06-21 16:29:04 +0200
committerTom de Vries <tdevries@suse.de>2023-06-21 16:29:04 +0200
commit83aa25512de00bbbc469d3bf2414e99c8374e0d7 (patch)
treed71d4cca955f3b821cd7de2539daac87fcc25183
parentb96cac16078d282ee0924296817c6eee52196669 (diff)
downloadgdb-83aa25512de00bbbc469d3bf2414e99c8374e0d7.zip
gdb-83aa25512de00bbbc469d3bf2414e99c8374e0d7.tar.gz
gdb-83aa25512de00bbbc469d3bf2414e99c8374e0d7.tar.bz2
[gdb/testsuite] Add have_host_locale
With test-case gdb.tui/pr30056.exp, I run into: ... sh: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)^M ... and then subsequently into: ... WARNING: timeout in accept_gdb_output FAIL: gdb.tui/pr30056.exp: Control-C ... This is on a CentOS 7 distro for powerpc64le. Either it has no C.UTF-8 support, or it's not installed: ... $ locale -a | grep ^C C $ ... Fix this by: - adding a new proc have_host_locale, and - using it in all test-cases using setenv LC_ALL. Tested on powerpc64le-linux and x86_64-linux.
-rw-r--r--gdb/testsuite/gdb.ada/non-ascii-latin-1.exp1
-rw-r--r--gdb/testsuite/gdb.ada/non-ascii-latin-3.exp1
-rw-r--r--gdb/testsuite/gdb.ada/non-ascii-utf-8.exp1
-rw-r--r--gdb/testsuite/gdb.base/utf8-identifiers.exp1
-rw-r--r--gdb/testsuite/gdb.rust/unicode.exp1
-rw-r--r--gdb/testsuite/gdb.tui/pr30056.exp1
-rw-r--r--gdb/testsuite/lib/gdb.exp36
7 files changed, 42 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ada/non-ascii-latin-1.exp b/gdb/testsuite/gdb.ada/non-ascii-latin-1.exp
index 3cdf53d..877a864 100644
--- a/gdb/testsuite/gdb.ada/non-ascii-latin-1.exp
+++ b/gdb/testsuite/gdb.ada/non-ascii-latin-1.exp
@@ -18,6 +18,7 @@
load_lib "ada.exp"
require allow_ada_tests
+require {have_host_locale C.UTF-8}
# Enable basic use of UTF-8. LC_ALL gets reset for each testfile. We
# want this despite the program itself using Latin-1, as this test is
diff --git a/gdb/testsuite/gdb.ada/non-ascii-latin-3.exp b/gdb/testsuite/gdb.ada/non-ascii-latin-3.exp
index 5b5ae29..285fa23 100644
--- a/gdb/testsuite/gdb.ada/non-ascii-latin-3.exp
+++ b/gdb/testsuite/gdb.ada/non-ascii-latin-3.exp
@@ -18,6 +18,7 @@
load_lib "ada.exp"
require allow_ada_tests
+require {have_host_locale C.UTF-8}
# Enable basic use of UTF-8. LC_ALL gets reset for each testfile. We
# want this despite the program itself using Latin-1, as this test is
diff --git a/gdb/testsuite/gdb.ada/non-ascii-utf-8.exp b/gdb/testsuite/gdb.ada/non-ascii-utf-8.exp
index c121161..acf13fc 100644
--- a/gdb/testsuite/gdb.ada/non-ascii-utf-8.exp
+++ b/gdb/testsuite/gdb.ada/non-ascii-utf-8.exp
@@ -18,6 +18,7 @@
load_lib "ada.exp"
require allow_ada_tests
+require {have_host_locale C.UTF-8}
# Enable basic use of UTF-8. LC_ALL gets reset for each testfile.
setenv LC_ALL C.UTF-8
diff --git a/gdb/testsuite/gdb.base/utf8-identifiers.exp b/gdb/testsuite/gdb.base/utf8-identifiers.exp
index 48dce3c..54a9a47 100644
--- a/gdb/testsuite/gdb.base/utf8-identifiers.exp
+++ b/gdb/testsuite/gdb.base/utf8-identifiers.exp
@@ -25,6 +25,7 @@ if { [is_c_compiler_gcc] } {
# Gcc fully supports fextended-identifiers starting GCC 5.
require {expr [gcc_major_version] >= 5}
}
+require {have_host_locale C.UTF-8}
standard_testfile
diff --git a/gdb/testsuite/gdb.rust/unicode.exp b/gdb/testsuite/gdb.rust/unicode.exp
index 97b37af..62619e8 100644
--- a/gdb/testsuite/gdb.rust/unicode.exp
+++ b/gdb/testsuite/gdb.rust/unicode.exp
@@ -18,6 +18,7 @@
load_lib rust-support.exp
require allow_rust_tests
require {can_compile rust}
+require {have_host_locale C.UTF-8}
# Non-ASCII identifiers were allowed starting in 1.53.
require {rust_at_least 1.53}
diff --git a/gdb/testsuite/gdb.tui/pr30056.exp b/gdb/testsuite/gdb.tui/pr30056.exp
index 48eaa57..55229dc 100644
--- a/gdb/testsuite/gdb.tui/pr30056.exp
+++ b/gdb/testsuite/gdb.tui/pr30056.exp
@@ -18,6 +18,7 @@
# This PR is fixed in the in-repo copy of readline. System readline may or
# may not be fixed, so skip this test-case.
require !with_system_readline
+require {have_host_locale C.UTF-8}
tuiterm_env
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index f214a6b..50fcb84 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -9794,5 +9794,41 @@ proc lappend_include_file { flags file } {
}
}
+# Return a list of supported host locales.
+
+gdb_caching_proc host_locales { } {
+ set result [remote_exec host "locale -a"]
+ set status [lindex $result 0]
+ set output [lindex $result 1]
+
+ if { $status != 0 } {
+ return {}
+ }
+
+ # Split into list.
+ set output [string trim $output]
+ set l [split $output \n]
+
+ # Trim items.
+ set l [lmap v $l { string trim $v }]
+
+ # Normalize items to lower-case.
+ set l [lmap v $l { string tolower $v }]
+
+ return $l
+}
+
+# Return 1 if host locale LOCALE is supported.
+
+proc have_host_locale { locale } {
+ # Normalize to lower-case.
+ set locale [string tolower $locale]
+ # Normalize to without dash.
+ set locale [string map { "-" "" } $locale]
+
+ set idx [lsearch [host_locales] $locale]
+ return [expr $idx != -1]
+}
+
# Always load compatibility stuff.
load_lib future.exp