From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by sourceware.org (Postfix) with ESMTPS id EDBCF3858D3C for ; Wed, 1 Mar 2023 20:25:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EDBCF3858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x12d.google.com with SMTP id g9so1529560ila.8 for ; Wed, 01 Mar 2023 12:25:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1677702346; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=KTV6LPfkPLFLO5xHXpsTqyCBrw7bc6wN5xtnK7nW/Lk=; b=QaFV5Gm/NmNd20Vbc7VDIx39cLsfSK51k9ipj5Mow/FRI7zF6qq2D8smoxng7EWjU7 wEqRfO+MkhyG4AVuI2g2IfDSIXJrYCEQ4kML8gzWrL2XIS5KMoMUUp7u6vZKV1gzuirR 2d9O0Mf6OJL1n8ZfUtU74XUkB+Oe2vndX6umEM1htptTS5TH56xK4iEJ5TwcryGNyehI oGz6cPL6vboemxL7SiQgB/7Mwi4vGd7FYXGtZXGauzw3bzPadLF3FFGrMO8p3jg8zKtn cIv2Pr2g7uMtTanTij72EuDC7QuFH0Fu53niy4BFQywSrM0HiP5mcrMjJ8TuJFVTuMcs RFfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677702346; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KTV6LPfkPLFLO5xHXpsTqyCBrw7bc6wN5xtnK7nW/Lk=; b=aPta0rKLrKqqCPFRWsQ1u0c20xSDDmRLatrcr5SsUpS7dAjrMFlCvcCsb0K4tCRrzS Xpg/zqNKqpMu3vIbojf1c5oedYF86mCoyKE5KktF3wsqifrCrwVA+K3dO0YSAX4Ni+4y zH4WeG8KMF80YIO8C32yQfqynHqcOIA7NlOVkhvGAsR7y1TQH0HP9ccMtGPwjkpfMJAj 1nfds/PrQHId8sKdZ06NEBIOlJbfMxsMzXntvhQWv3ZDEwkqUGI3W2WqY6ikXBS/s6JN uEAZxLSW/2z8wqVLeRlNL1PjW1vPvQo9uCTVPOpMhYsEsjZu+uN+ITgZGHuH8NqEqc/d fFdg== X-Gm-Message-State: AO0yUKWzEthma0maramg1tcLydGVGZCK5SeGV/W92LzNfN8aERlFMpkl MKouocDdnML/rpVJR0yKr1IreyKhekKQ0SqL X-Google-Smtp-Source: AK7set+bm4dC4Ja/MF+de1zF5PM0HIYwiXqCw8WamHTiUBTQ85CDECUS1zNQQfwusxrM2bxrXhm0fQ== X-Received: by 2002:a05:6e02:1542:b0:315:5141:339a with SMTP id j2-20020a056e02154200b003155141339amr6944156ilu.7.1677702346163; Wed, 01 Mar 2023 12:25:46 -0800 (PST) Received: from localhost.localdomain (75-166-130-93.hlrn.qwest.net. [75.166.130.93]) by smtp.gmail.com with ESMTPSA id v8-20020a927a08000000b0031578323bc5sm424633ilc.56.2023.03.01.12.25.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Mar 2023 12:25:45 -0800 (PST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Introduce rust_at_least helper proc Date: Wed, 1 Mar 2023 13:25:38 -0700 Message-Id: <20230301202538.3291371-1-tromey@adacore.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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'. --- gdb/testsuite/gdb.rust/rawids.exp | 8 +------- gdb/testsuite/gdb.rust/unicode.exp | 8 +------- gdb/testsuite/gdb.rust/unsized.exp | 5 +---- gdb/testsuite/lib/rust-support.exp | 11 +++++++++++ 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/gdb/testsuite/gdb.rust/rawids.exp b/gdb/testsuite/gdb.rust/rawids.exp index 976b723833e..8b7db877328 100644 --- a/gdb/testsuite/gdb.rust/rawids.exp +++ b/gdb/testsuite/gdb.rust/rawids.exp @@ -16,13 +16,7 @@ # Test raw identifiers. 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 allow_rust_tests {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 2b4766b5553..c2bc0ef960f 100644 --- a/gdb/testsuite/gdb.rust/unicode.exp +++ b/gdb/testsuite/gdb.rust/unicode.exp @@ -16,14 +16,8 @@ # 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 {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 f81be8a3078..b3bd2d7d1c5 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 {[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 df517647ce9..c4a403732dc 100644 --- a/gdb/testsuite/lib/rust-support.exp +++ b/gdb/testsuite/lib/rust-support.exp @@ -112,3 +112,14 @@ gdb_caching_proc rust_compiler_version { } return 0.0 } + +# A helper that checks that the rust compiler is at least MAJOR.MINOR. +# This is handy for use with 'require'. +proc rust_at_least {major minor} { + set v [split [rust_compiler_version] .] + if {[lindex $v 0] < $major + || ([lindex $v 0] == $major && [lindex $v 1] < $minor)} { + return 0 + } + return 1 +} -- 2.39.1