public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Introduce rust_at_least helper proc
@ 2023-03-29 16:14 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2023-03-29 16:14 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=52fcd590bdabebf6cb4baa271cc1208f2541e6d4
commit 52fcd590bdabebf6cb4baa271cc1208f2541e6d4
Author: Tom Tromey <tromey@adacore.com>
Date: Mon Feb 27 13:23:35 2023 -0700
Introduce rust_at_least helper proc
This adds a 'rust_at_least' helper proc, for checking the version of
the Rust compiler in use. It then changes various tests to use this
with 'require'.
Diff:
---
gdb/testsuite/gdb.rust/rawids.exp | 7 +------
gdb/testsuite/gdb.rust/unicode.exp | 6 +-----
gdb/testsuite/gdb.rust/unsized.exp | 5 +----
gdb/testsuite/lib/rust-support.exp | 25 +++++++++++++++++++++++++
4 files changed, 28 insertions(+), 15 deletions(-)
diff --git a/gdb/testsuite/gdb.rust/rawids.exp b/gdb/testsuite/gdb.rust/rawids.exp
index 56d1e5f64b3..55e1b7ffbdd 100644
--- a/gdb/testsuite/gdb.rust/rawids.exp
+++ b/gdb/testsuite/gdb.rust/rawids.exp
@@ -18,12 +18,7 @@
load_lib rust-support.exp
require allow_rust_tests
require {can_compile rust}
-
-set v [split [rust_compiler_version] .]
-if {[lindex $v 0] == 1 && [lindex $v 1] < 30} {
- untested "raw identifiers require rust 1.30 or greater"
- return -1
-}
+require {rust_at_least 1.30}
standard_testfile .rs
if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug rust}]} {
diff --git a/gdb/testsuite/gdb.rust/unicode.exp b/gdb/testsuite/gdb.rust/unicode.exp
index 7124934c8d5..97b37af316a 100644
--- a/gdb/testsuite/gdb.rust/unicode.exp
+++ b/gdb/testsuite/gdb.rust/unicode.exp
@@ -20,11 +20,7 @@ require allow_rust_tests
require {can_compile rust}
# Non-ASCII identifiers were allowed starting in 1.53.
-set v [split [rust_compiler_version] .]
-if {[lindex $v 0] == 1 && [lindex $v 1] < 53} {
- untested "this test requires rust 1.53 or greater"
- return -1
-}
+require {rust_at_least 1.53}
# 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.rust/unsized.exp b/gdb/testsuite/gdb.rust/unsized.exp
index a12d8f0bac4..f6d39dd6248 100644
--- a/gdb/testsuite/gdb.rust/unsized.exp
+++ b/gdb/testsuite/gdb.rust/unsized.exp
@@ -32,10 +32,7 @@ if {![runto ${srcfile}:$line]} {
gdb_test "ptype us" " = .*V<\\\[u8\\\]>.*"
-set v [split [rust_compiler_version] .]
-# The necessary debuginfo generation landed in 1.60, but had a bug
-# that was fixed in 1.61.
-if {[lindex $v 0] > 1 || [lindex $v 1] >= 61} {
+if {[rust_at_least 1.61]} {
gdb_test "print us2" " = .*Box<.*> \\\[1, 2, 3\\\]"
gdb_test "ptype us2" "type = .*"
}
diff --git a/gdb/testsuite/lib/rust-support.exp b/gdb/testsuite/lib/rust-support.exp
index f3739e2ce02..381871e22f4 100644
--- a/gdb/testsuite/lib/rust-support.exp
+++ b/gdb/testsuite/lib/rust-support.exp
@@ -112,3 +112,28 @@ gdb_caching_proc rust_compiler_version {} {
}
return 0.0
}
+
+# A helper that checks that the rust compiler is at least the given
+# version. This is handy for use with 'require'.
+proc rust_at_least {atleast} {
+ foreach n1 [split [rust_compiler_version] .] n2 [split $atleast .] {
+ if {$n1 == ""} {
+ # Have 1.2, wanted 1.2.1.
+ return 0
+ }
+ if {$n2 == ""} {
+ # Have 1.2.1, wanted 1.2.
+ return 1
+ }
+ if {$n1 > $n2} {
+ # Have 1.3, wanted 1.2.
+ return 1
+ }
+ if {$n1 < $n2} {
+ # Have 1.1, wanted 1.2.
+ return 0
+ }
+ }
+ # Completely equal.
+ return 1
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-29 16:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-29 16:14 [binutils-gdb] Introduce rust_at_least helper proc Tom Tromey
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).