From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by sourceware.org (Postfix) with ESMTPS id 8BC9D3858C5E for ; Fri, 3 Mar 2023 18:38:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8BC9D3858C5E 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-io1-xd31.google.com with SMTP id v10so1351245iox.8 for ; Fri, 03 Mar 2023 10:38:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1677868718; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=+aLAFMCVjBsk8iqgilsjTdJEWB8xC/Xybr3/DqN/CD0=; b=Nv+7CRmkl40c/vu8eJ3YqxFYQptcZ9bano/95V26R4YE4jI1umAhIut0xUV171jiy4 0YdobddBhHj1tCvrxzRqmHdcXkf2B+XrF1cHC/TlR3sQ5/otP25uRpN5DtNFW0ZMmhl2 JtqqU+YqkY/1emcFkq8lrZOJexxOyMFUFtjIU3Tyg9Uz9MTGmNOgGpF/eoEYSvUEN2EX O6zhUd7K67rV5jM9idqeyUGmgYKjK6W7QMN09Bs3oqXdg+GRiMKYBFbWfUKVelf8n6yQ vlqhsXqxRgkOt3eK6RZULiGNshUwu3Jlgne6Bm2JtiMVqnrLOqxhpIGXQB/zJswfP2SR HD3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677868718; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+aLAFMCVjBsk8iqgilsjTdJEWB8xC/Xybr3/DqN/CD0=; b=436Fa2Uvry5ueyhUn3KlQYQ0+p9kzJdTxsf7F64QHp9bHdOSrlKXlxRw2XGm6vsspg LPRGPSNFaNFZmKoC8R/QoMB8VGPqGamuqeZp7ZfXe28KO89pAnNOZ8GAUtuASfDRkA5T sBfMh0r21us+0pGf/Lu9edxgRzttgoYBWPpUPLeX8hdmwsGXdhhG9TxmDsIxf5X9jOpo BUsCynWLD+mMTpA32py9dFKOxtaDSZ3vhx6igPodi/gyR1Z2di9dL4sygvO+yztZgVak hDL1qqEkJQQPgfy1+Ie8l6B8G6ZxC+HMBLaei+Tfg6l9H/WPME1oa7MtZD6T6NKU2d4+ eqBg== X-Gm-Message-State: AO0yUKUiYrkg1MkeqxBqQpPBLVZ/0w7O87CcmCLN9Iys1MVA1LxbMIS5 xoFl1H8qm3sOMsR/huu89OfYRw== X-Google-Smtp-Source: AK7set+Z8sRGoVF7i/xGcyfVGuAf+GnVUYGBNvIsuFqEo7QGXvJUTP4i1vJwIYf3NZ2SjjLYeeO+Sw== X-Received: by 2002:a6b:7a4b:0:b0:74c:c594:beaf with SMTP id k11-20020a6b7a4b000000b0074cc594beafmr1818073iop.18.1677868717707; Fri, 03 Mar 2023 10:38:37 -0800 (PST) Received: from murgatroyd (75-166-130-93.hlrn.qwest.net. [75.166.130.93]) by smtp.gmail.com with ESMTPSA id y6-20020a6bc406000000b00743fe29dd56sm935374ioa.4.2023.03.03.10.38.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Mar 2023 10:38:37 -0800 (PST) From: Tom Tromey To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Introduce rust_at_least helper proc References: <20230301202538.3291371-1-tromey@adacore.com> X-Attribution: Tom Date: Fri, 03 Mar 2023 11:38:36 -0700 In-Reply-To: <20230301202538.3291371-1-tromey@adacore.com> (Tom Tromey's message of "Wed, 1 Mar 2023 13:25:38 -0700") Message-ID: <87sfel8ytv.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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: >>>>> "Tom" == Tom Tromey writes: Tom> This adds a 'rust_at_least' helper proc, for checking the version of Tom> the Rust compiler in use. It then changes various tests to use this Tom> with 'require'. I decided later that it would be nicer to just pass a version number, rather than a list. So, here is v2. Tom commit 4c3abcc38a02d89b27b8bc1b9a82a0112930ec7d Author: Tom Tromey 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 --git a/gdb/testsuite/gdb.rust/rawids.exp b/gdb/testsuite/gdb.rust/rawids.exp index 976b723833e..3c65efb30c0 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..3de8fefdcc0 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..c81a93a9303 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..85adbb9bb8f 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 +}