From patchwork Thu Oct 26 12:34:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 158517 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp638983vqb; Thu, 26 Oct 2023 05:34:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFIChwo/7sUsuS2Iowol2zGmD7Z61LRBHGr7voYma+J4PkXA9/Tlw2MdBwI1bDYPEjsMAtl X-Received: by 2002:ac8:5bd1:0:b0:417:9994:eb75 with SMTP id b17-20020ac85bd1000000b004179994eb75mr20792920qtb.21.1698323669957; Thu, 26 Oct 2023 05:34:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698323669; cv=pass; d=google.com; s=arc-20160816; b=Zi5nN2K7mRAsInsufEAL6eUh9xR72GoSUs1MX3N8RtlNSN5LBrCmHuJV9GZmVxjpp5 FPaPPeNaG3k2jyT9n/po2DqJFgW1wov6qAFiLCC38qDhMombHsFi1D7UukVfrJIq8jeT /yxpfRHSrXXniwoIe8IBbgYiZo14aLSWeVbxSsRpt+EX8TG0maV6iiJK1pJF7fwAkwhR mcme/0jq6WZnwoOmAS7E0cTED8ygVcJzEPLysl1s0yg0TtljZJAlt1Ao/rMkR0asAdxs 36ccxVDOWvirRotxFIKIOyt5HiJxXSnP4XUOzCDg9+fN9mZLBEhHwoHRcxi9ayICfi8y V5uQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:user-agent :message-id:date:subject:mail-followup-to:to:from:arc-filter :dmarc-filter:delivered-to; bh=dwM5DXHXOzdxlMJex5NEN18jnlqGgqiGn2ZWsTJkQaw=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=GbdPVvjapI0mZQWRK67fWxvwPpXxgBxpbC18WpB9mTyAkinN8zdYC35yrzt1U0kVmX i5zp+vy7qXJ3Xvj/OlesdHPYwo8O7nTF26YkVYoelmYrguNeO9NKsHpsxVWlztBkIDlI uO4X4jOGCIOIXjTK9L86bQDeSvkfOdtxarsO3xQMpR0neutGiKaxVeBsNSNu94DrFAi9 08NAJgAjlfe/mS/bvbuwuSvkATgeovpwdqBHDjZ3oNGWSm+Rs/YMy9Bo/xNAQJLUelwK gyERNslTeHK1fEFteIFpiK6C4ypNPOt8rbCC9mKxVt7tY7Oxp433HHKDE/FX2jw9afKN 1iFw== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id r16-20020a05622a035000b004188c21b6f8si9447062qtw.192.2023.10.26.05.34.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 05:34:29 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B853D3858CD1 for ; Thu, 26 Oct 2023 12:34:29 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 1DBB1385B53E for ; Thu, 26 Oct 2023 12:34:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1DBB1385B53E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1DBB1385B53E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698323647; cv=none; b=KXAaPNLsvWQGIozruNTwLAHpyfAg166SrUW4PfdZYwflHB7/OFnx86Kyvks9ryEcr5Y388+iW4uC7JccKo4cl2Y+kMIBx4vLhNrVGK/DZBZlguCanGEZrNn+ehK8ZsE0I8KEdXNcLC271OoLKJ0w4aXfIg4OZu3htjKKp7xcNS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698323647; c=relaxed/simple; bh=49TIVjtKzhmSyNtGMIXpVFrSzvmRzY7UEGbLruXQ7es=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=woQ/XRO1CCLakZ7V/6/vD0MWf1RdVbQl3BpHoHUnJUO/zWhzWd/qBGLJAcIOwoZNk0kEemdCL2pTPdyXEpe2QG/oNK+shH8qxNsRuEhecgl8Y6L+CR8ev/eZMzAeYUV15dCUBrHoXHDpJMpTcvxKW2T76JnERn9Driauq/vdy00= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0DAC12F4 for ; Thu, 26 Oct 2023 05:34:47 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 23E1F3F738 for ; Thu, 26 Oct 2023 05:34:05 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [PATCH] testsuite: Allow general skips/requires in PCH tests Date: Thu, 26 Oct 2023 13:34:03 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-23.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780821440536401568 X-GMAIL-MSGID: 1780821440536401568 dg-pch.exp handled dg-require-effective-target pch_supported_debug as a special case, by grepping the source code. This patch tries to generalise it to other dg-require-effective-targets, and to dg-skip-if. There also seemed to be some errors in check-flags. It used: lappend $args [list ] which treats the contents of args as a variable name. I think it was supposed to be "lappend args" instead. From the later code, the element was supposed to be itself, rather than a singleton list containing . We can also save some time by doing the common early-exit first. Doing this removes the need to specify the dg-require-effective-target in both files. Tested by faking unsupported debug and checking that the tests were still correctly skipped. Tested on aarch64-linux-gnu. OK to install? Richard gcc/testsuite/ * lib/target-supports-dg.exp (check-flags): Move default argument handling further up. Fix a couple of issues in the lappends. Avoid frobbing the compiler flags if the return value is already known to be 1. * lib/dg-pch.exp (dg-flags-pch): Process the dg-skip-if and dg-require-effective-target directives to see whether the assembly test should be skipped. * gcc.dg/pch/valid-1.c: Remove dg-require-effective-target. * gcc.dg/pch/valid-1b.c: Likewise. --- gcc/testsuite/gcc.dg/pch/valid-1.c | 1 - gcc/testsuite/gcc.dg/pch/valid-1b.c | 1 - gcc/testsuite/lib/dg-pch.exp | 24 ++++++++++++-- gcc/testsuite/lib/target-supports-dg.exp | 40 ++++++++++++------------ 4 files changed, 42 insertions(+), 24 deletions(-) diff --git a/gcc/testsuite/gcc.dg/pch/valid-1.c b/gcc/testsuite/gcc.dg/pch/valid-1.c index 6e9abdaef3a..b950d0d4c64 100644 --- a/gcc/testsuite/gcc.dg/pch/valid-1.c +++ b/gcc/testsuite/gcc.dg/pch/valid-1.c @@ -1,4 +1,3 @@ -/* { dg-require-effective-target pch_supported_debug } */ /* { dg-options "-I. -Winvalid-pch -g" } */ #include "valid-1.h"/* { dg-warning "created with .none. debug info, but used with" } */ diff --git a/gcc/testsuite/gcc.dg/pch/valid-1b.c b/gcc/testsuite/gcc.dg/pch/valid-1b.c index 3113d0f744d..a2709967c07 100644 --- a/gcc/testsuite/gcc.dg/pch/valid-1b.c +++ b/gcc/testsuite/gcc.dg/pch/valid-1b.c @@ -1,4 +1,3 @@ -/* { dg-require-effective-target pch_supported_debug } */ /* { dg-options "-I. -Winvalid-pch -g0" } */ #include "valid-1b.h" diff --git a/gcc/testsuite/lib/dg-pch.exp b/gcc/testsuite/lib/dg-pch.exp index 6b09e8c0478..b6fefaa0286 100644 --- a/gcc/testsuite/lib/dg-pch.exp +++ b/gcc/testsuite/lib/dg-pch.exp @@ -100,6 +100,27 @@ proc dg-flags-pch { subdir test otherflags options suffix } { # For the rest, the default is to compile to .s. set dg-do-what-default compile + # Process the target selectors to see whether the remaining + # part of the test should be skipped. + # + # ??? This doesn't currently handle flag-specific skips, + # based on dg-options. + set dg-do-what [list compile "" P] + set dg-extra-tool-flags "" + foreach op [dg-get-options "./$bname$suffix"] { + switch [lindex $op 0] { + dg-require-effective-target - + dg-skip-if { + if { [catch "$op" msg] } { + perror "$bname$suffix: $msg for \"$op\"" + } + } + } + } + if { [lindex ${dg-do-what} 1] == "N" } { + continue + } + set have_errs [llength [grep $test "{\[ \t\]\+dg-error\[ \t\]\+.*\[ \t\]\+}"]] if { [ file_on_host exists "$bname$suffix.gch" ] } { @@ -134,8 +155,7 @@ proc dg-flags-pch { subdir test otherflags options suffix } { fail "$nshort $flags assembly comparison" } } - } elseif { $pch_unsupported_debug == 0 \ - || [llength [grep $test "{\[ \t\]\+dg-require-effective-target\[ \t\]\+pch_supported_debug\[ \t\]\+.*\[ \t\]\+}"]] > 0 } { + } else { verbose -log "pch file '$bname$suffix.gch' missing" fail "$nshort $flags" if { !$have_errs } { diff --git a/gcc/testsuite/lib/target-supports-dg.exp b/gcc/testsuite/lib/target-supports-dg.exp index a80970f1ac2..b5658c1c33e 100644 --- a/gcc/testsuite/lib/target-supports-dg.exp +++ b/gcc/testsuite/lib/target-supports-dg.exp @@ -334,6 +334,23 @@ proc check-flags { args } { # The args are within another list; pull them out. set args [lindex $args 0] + # The next two arguments are optional. If they were not specified, + # use the defaults. + if { [llength $args] == 2 } { + lappend args "*" + } + if { [llength $args] == 3 } { + lappend args "" + } + + # If the option strings are the defaults, or the same as the + # defaults, there is no need to call check_conditional_xfail to + # compare them to the actual options. + if { [string compare [lindex $args 2] "*"] == 0 + && [string compare [lindex $args 3] "" ] == 0 } { + return 1 + } + # Start the list with a dummy tool name so the list will match "*" # if there are no flags. set compiler_flags " toolname " @@ -350,26 +367,9 @@ proc check-flags { args } { append compiler_flags "[board_info $dest multilib_flags] " } - # The next two arguments are optional. If they were not specified, - # use the defaults. - if { [llength $args] == 2 } { - lappend $args [list "*"] - } - if { [llength $args] == 3 } { - lappend $args [list ""] - } - - # If the option strings are the defaults, or the same as the - # defaults, there is no need to call check_conditional_xfail to - # compare them to the actual options. - if { [string compare [lindex $args 2] "*"] == 0 - && [string compare [lindex $args 3] "" ] == 0 } { - set result 1 - } else { - # The target list might be an effective-target keyword, so replace - # the original list with "*-*-*", since we already know it matches. - set result [check_conditional_xfail [lreplace $args 1 1 "*-*-*"]] - } + # The target list might be an effective-target keyword, so replace + # the original list with "*-*-*", since we already know it matches. + set result [check_conditional_xfail [lreplace $args 1 1 "*-*-*"]] # Any value in this variable was left over from an earlier test. set compiler_flags ""