diff --git a/gdb/testsuite/gdb.rust/rawids.exp b/gdb/testsuite/gdb.rust/rawids.exp index 976b723833e..ec613048bf0 100644 --- a/gdb/testsuite/gdb.rust/rawids.exp +++ b/gdb/testsuite/gdb.rust/rawids.exp @@ -17,12 +17,7 @@ load_lib rust-support.exp require allow_rust_tests - -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 {version_compare [rust_compiler_version] >= {1 30 0}} 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 2b4766b5553..9f27fddcad4 100644 --- a/gdb/testsuite/gdb.rust/unicode.exp +++ b/gdb/testsuite/gdb.rust/unicode.exp @@ -16,14 +16,9 @@ # Test raw identifiers. load_lib rust-support.exp -require allow_rust_tests - # 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 allow_rust_tests +require {version_compare [rust_compiler_version] >= {1 53 0}} # 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 f81be8a3078..07f6c2e7a21 100644 --- a/gdb/testsuite/gdb.rust/unsized.exp +++ b/gdb/testsuite/gdb.rust/unsized.exp @@ -31,10 +31,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 {[version_compare [rust_compiler_version] >= {1 61 0}]} { gdb_test "print us2" " = .*Box<.*> \\\[1, 2, 3\\\]" gdb_test "ptype us2" "type = .*" } diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp index fb5c953a6c4..371c7a86fc2 100644 --- a/gdb/testsuite/lib/gdb-utils.exp +++ b/gdb/testsuite/lib/gdb-utils.exp @@ -115,6 +115,7 @@ proc version_compare { l1 op l2 } { "<" {} "<=" { return [expr [version_compare $l1 < $l2] \ || [version_compare $l1 == $l2]]} + ">=" { return [expr [version_compare $l2 <= $l1]] } default { error "unsupported op: $op" } } diff --git a/gdb/testsuite/lib/rust-support.exp b/gdb/testsuite/lib/rust-support.exp index f3739e2ce02..187087a47cb 100644 --- a/gdb/testsuite/lib/rust-support.exp +++ b/gdb/testsuite/lib/rust-support.exp @@ -105,10 +105,11 @@ gdb_caching_proc rust_compiler_version {} { set output [lindex [remote_exec host "$rustc --version --verbose"] 1] foreach line [split $output \n] { if {[regexp "rustc (\[0-9.\]+).*\$" $output ignore version]} { + set version [split $version .] return $version } } verbose "could not match rustc version output: $output" } - return 0.0 + return [list 0 0] }