gdb/gdb-testsuite-add-have_host_locale.patch

149 lines
4.5 KiB
Diff

From f26e9f1ce8e47bca399116a99ffdbf0aff9f2080 Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@suse.de>
Date: Mon, 12 Jun 2023 18:00:10 +0200
Subject: [PATCH 3/9] [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.
---
gdb/testsuite/gdb.ada/non-ascii-latin-1.exp | 1 +
gdb/testsuite/gdb.ada/non-ascii-latin-3.exp | 1 +
gdb/testsuite/gdb.ada/non-ascii-utf-8.exp | 1 +
gdb/testsuite/gdb.base/utf8-identifiers.exp | 2 ++
gdb/testsuite/gdb.rust/unicode.exp | 1 +
gdb/testsuite/lib/gdb.exp | 36 +++++++++++++++++++++
6 files changed, 42 insertions(+)
diff --git a/gdb/testsuite/gdb.ada/non-ascii-latin-1.exp b/gdb/testsuite/gdb.ada/non-ascii-latin-1.exp
index ad4ccde625b..472e049737b 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"
if { [skip_ada_tests] } { return -1 }
+if { ![have_host_locale C.UTF-8] } { return -1 }
# 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 f2bdd99d243..6f826427ad3 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"
if { [skip_ada_tests] } { return -1 }
+if { ![have_host_locale C.UTF-8] } { return -1 }
# 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 d3c1ac4d0cf..7dcfb71bbb3 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"
if { [skip_ada_tests] } { return -1 }
+if { ![have_host_locale C.UTF-8] } { return -1 }
# 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 a6ef80fb0bd..7babe237dfb 100644
--- a/gdb/testsuite/gdb.base/utf8-identifiers.exp
+++ b/gdb/testsuite/gdb.base/utf8-identifiers.exp
@@ -21,6 +21,8 @@
load_lib completion-support.exp
+if { ![have_host_locale C.UTF-8] } { return -1 }
+
standard_testfile
# Enable basic use of UTF-8. LC_ALL gets reset for each testfile.
diff --git a/gdb/testsuite/gdb.rust/unicode.exp b/gdb/testsuite/gdb.rust/unicode.exp
index 63ed8d1250c..185eae008f6 100644
--- a/gdb/testsuite/gdb.rust/unicode.exp
+++ b/gdb/testsuite/gdb.rust/unicode.exp
@@ -19,6 +19,7 @@ load_lib rust-support.exp
if {[skip_rust_tests]} {
return
}
+if { ![have_host_locale C.UTF-8] } { return }
# Non-ASCII identifiers were allowed starting in 1.53.
set v [split [rust_compiler_version] .]
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 0b8a15f61cb..cd043ce3436 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -9452,5 +9452,41 @@ proc have_syscall { name } {
return [gdb_can_simple_compile have_syscall_$name $src object]
}
+# 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
--
2.35.3