From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [pushed] [gdb/testsuite] Factor out proc linux_kernel_version
Date: Tue, 14 Feb 2023 11:54:16 +0100 [thread overview]
Message-ID: <20230214105416.6677-1-tdevries@suse.de> (raw)
Factor out new proc linux_kernel_version from test-case
gdb.arch/i386-pkru.exp.
Tested on x86_64-linux.
---
gdb/testsuite/gdb.arch/i386-pkru.exp | 20 ++++++--------------
gdb/testsuite/lib/gdb.exp | 23 +++++++++++++++++++++++
2 files changed, 29 insertions(+), 14 deletions(-)
diff --git a/gdb/testsuite/gdb.arch/i386-pkru.exp b/gdb/testsuite/gdb.arch/i386-pkru.exp
index 90d8c1d9d4c..1f047df68ef 100644
--- a/gdb/testsuite/gdb.arch/i386-pkru.exp
+++ b/gdb/testsuite/gdb.arch/i386-pkru.exp
@@ -59,20 +59,12 @@ if { !$supports_pkru } {
# the PKRU using ptrace, see commit 4a804c4f8356 ("x86/fpu: Allow PKRU to be
# (once again) written by ptrace.").
set have_xfail 0
-if { [istarget *-*-linux*] } {
- set res [remote_exec target "uname -r"]
- set status [lindex $res 0]
- set output [lindex $res 1]
-
- set re ^($decimal)\\.($decimal)\\.($decimal)
- if { $status == 0
- && [regexp $re $output dummy v1 v2 v3] == 1 } {
- set v [list $v1 $v2 $v3]
- set have_xfail \
- [expr \
- [version_compare [list 5 14 0] <= $v] \
- && [version_compare $v < [list 6 2 0]]]
- }
+set v [linux_kernel_version]
+if { $v != {} } {
+ set have_xfail \
+ [expr \
+ [version_compare [list 5 14 0] <= $v] \
+ && [version_compare $v < [list 6 2 0]]]
}
# Test pkru register at startup
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 7f98f080328..e48228ed4f6 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -9374,5 +9374,28 @@ proc has_dependency { file dep } {
return [regexp $dep $output]
}
+# Detect linux kernel version and return as list of 3 numbers: major, minor,
+# and patchlevel. On failure, return an empty list.
+
+gdb_caching_proc linux_kernel_version {
+ if { ![istarget *-*-linux*] } {
+ return {}
+ }
+
+ set res [remote_exec target "uname -r"]
+ set status [lindex $res 0]
+ set output [lindex $res 1]
+ if { $status != 0 } {
+ return {}
+ }
+
+ set re ^($::decimal)\\.($::decimal)\\.($::decimal)
+ if { [regexp $re $output dummy v1 v2 v3] != 1 } {
+ return {}
+ }
+
+ return [list $v1 $v2 $v3]
+}
+
# Always load compatibility stuff.
load_lib future.exp
base-commit: 0d79a2a8e2d91fc258ac795c19c13e3ab505a6c2
--
2.35.3
reply other threads:[~2023-02-14 10:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230214105416.6677-1-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).