From patchwork Tue Jul 24 18:13:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janis Johnson X-Patchwork-Id: 172995 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 90E652C0088 for ; Wed, 25 Jul 2012 04:13:53 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1343758433; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Message-ID:Date:From:Reply-To:User-Agent:MIME-Version: To:Subject:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=XysEkKqQnyFkHZbYnhSeDA+KZ0g=; b=GLbuL+nYHHAZVOX 23bJ9EY4HIlNz4SfRpeMaGzw62RJah8rXNJGDh6Hr/Frcl0YQa4ZibaSxTB+vMit aDF7alAsC723Nf2YPUkVWosf6NMZ6HrWJAbA485QfuuGwHLa0YVIbU4zrlp2EiKs Lb1XX3t7iCPOs6FwpMDLdVdTQpVA= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Message-ID:Date:From:Reply-To:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=FCSAOSW5iWb77brOYepvfqxBIaqcxgtj39I5X4jGjmc4nHUCXB7PcrkcvpkEZo TAZ29KXk/nLthOKeiHWS9Kuvsxk8NwfdEtuNgo+0LP5IBM/wkW5lKcMSjV9OhCM6 wEjvKarBSrjiTFmxIk6UdiwJmXt3vXm8Odp7vMoU9yktI=; Received: (qmail 14439 invoked by alias); 24 Jul 2012 18:13:46 -0000 Received: (qmail 14429 invoked by uid 22791); 24 Jul 2012 18:13:44 -0000 X-SWARE-Spam-Status: No, hits=-3.7 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 24 Jul 2012 18:13:30 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1Stjbs-00076J-R4 from Janis_Johnson@mentor.com for gcc-patches@gcc.gnu.org; Tue, 24 Jul 2012 11:13:28 -0700 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 24 Jul 2012 11:13:30 -0700 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.1.289.1; Tue, 24 Jul 2012 11:13:27 -0700 Message-ID: <500EE5E1.8090204@mentor.com> Date: Tue, 24 Jul 2012 11:13:53 -0700 From: Janis Johnson Reply-To: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.28) Gecko/20120313 Thunderbird/3.1.20 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" Subject: [testsuite] support using "target" and "xfail" together Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch allows the use of both "target" and "xfail" in the selector of any test directive that currently takes either "target" or "xfail": { target selector1 xfail selector2 } The test is only used if the "target" selector is matched, and the test is expected to fail if the "xfail" selector is matched. The keyword "target" must come first; it doesn't make sense to me otherwise because the xfail part shouldn't be processed if the target selector doesn't match. Tested with i686-pc-linux-gnu for c,c++,gfortran,objc,obj-c++ plus with examples using the new feature, with and without errors. I'd like some feedback before checking this in so I'll wait at least a couple of days. I plan to put it on the 4.7 branch also. Janis 2012-07-24 Janis Johnson doc/sourcebuild.texi (Selectors): Document the use of target and xfail used together. testsuite/ * lib/target-supports-dg.exp (dg-require-effective-target, dg-skip-if, dg-xfail-if, dg-xfail-run-if, dg-shouldfail): Call dg-process-target-1 instead of dg-process-target. (dg-process-target-1): Rename from dg-process-target. (dg-process-target): New. Index: doc/sourcebuild.texi =================================================================== --- doc/sourcebuild.texi (revision 189790) +++ doc/sourcebuild.texi (working copy) @@ -1232,15 +1232,18 @@ A selector is: @itemize @bullet -@item one or more target triplets, possibly including wildcard characters +@item one or more target triplets, possibly including wildcard characters; +use @samp{*-*-*} to match any target @item a single effective-target keyword (@pxref{Effective-Target Keywords}) @item a logical expression @end itemize -Depending on the -context, the selector specifies whether a test is skipped and reported -as unsupported or is expected to fail. Use @samp{*-*-*} to match any -target. +Depending on the context, the selector specifies whether a test is +skipped and reported as unsupported or is expected to fail. A context +that allows either @samp{target} or @samp{xfail} also allows +@samp{@{ target @var{selector1} xfail @var{selector2} @}} +to skip the test for targets that don't match @var{selector1} and the +test to fail for targets that match @var{selector2}. A selector expression appears within curly braces and uses a single logical operator: one of @samp{!}, @samp{&&}, or @samp{||}. An Index: testsuite/lib/target-supports-dg.exp =================================================================== --- testsuite/lib/target-supports-dg.exp (revision 189790) +++ testsuite/lib/target-supports-dg.exp (working copy) @@ -208,7 +208,7 @@ # Evaluate selector if present. if { [llength $args] == 2 } { - switch [dg-process-target [lindex $args 1]] { + switch [dg-process-target-1 [lindex $args 1]] { "S" { } "N" { return } } @@ -359,7 +359,7 @@ } set selector [list target [lindex $args 1]] - if { [dg-process-target $selector] == "S" } { + if { [dg-process-target-1 $selector] == "S" } { if [check-flags $args] { upvar dg-do-what dg-do-what set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"] @@ -383,7 +383,7 @@ } set selector [list target [lindex $args 1]] - if { [dg-process-target $selector] == "S" } { + if { [dg-process-target-1 $selector] == "S" } { global compiler_conditional_xfail_data # The target list might be an effective-target keyword. Replace @@ -418,7 +418,7 @@ } set selector [list target [lindex $args 1]] - if { [dg-process-target $selector] == "S" } { + if { [dg-process-target-1 $selector] == "S" } { if [check-flags $args] { upvar dg-do-what dg-do-what set dg-do-what [list [lindex ${dg-do-what} 0] "S" "F"] @@ -442,7 +442,7 @@ set args [lreplace $args 0 0] if { [llength $args] > 1 } { set selector [list target [lindex $args 1]] - if { [dg-process-target $selector] == "S" } { + if { [dg-process-target-1 $selector] == "S" } { # The target matches, now check the flags. if [check-flags $args] { set shouldfail 1 @@ -457,16 +457,19 @@ # support use of an effective-target keyword in place of a list of # target triplets to xfail or skip a test. # -# selector is one of: -# xfail target-triplet-1 ... -# xfail effective-target-keyword -# xfail selector-expression -# target target-triplet-1 ... -# target effective-target-keyword -# target selector-expression +# The argument to dg-process-target is the keyword "target" or "xfail" +# followed by a selector: +# target-triplet-1 ... +# effective-target-keyword +# selector-expression # # For a target list the result is "S" if the target is selected, "N" otherwise. # For an xfail list the result is "F" if the target is affected, "P" otherwise. + +# In contexts that allow either "target" or "xfail" the argument can be +# target selector1 xfail selector2 +# which returns "N" if selector1 is not selected, otherwise the result of +# "xfail selector2". # # A selector expression appears within curly braces and uses a single logical # operator: !, &&, or ||. An operand is another selector expression, an @@ -526,9 +529,11 @@ return $answer } - proc dg-process-target { args } { - verbose "replacement dg-process-target: `$args'" 2 - + # Evaluate "target selector" or "xfail selector". + + proc dg-process-target-1 { args } { + verbose "dg-process-target-1: `$args'" 2 + # Extract the 'what' keyword from the argument list. set selector [string trim [lindex $args 0]] if [regexp "^xfail " $selector] { @@ -564,4 +569,29 @@ # the list of target triplets. return [saved-dg-process-target $selector] } + + # Intercept calls to the DejaGnu function. In addition to + # processing "target selector" or "xfail selector", handle + # "target selector1 xfail selector2". + + proc dg-process-target { args } { + verbose "replacement dg-process-target: `$args'" 2 + + set selector [string trim [lindex $args 0]] + + # If the argument list contains both 'target' and 'xfail', + # process 'target' and, if that succeeds, process 'xfail'. + if [regexp "^target .* xfail .*" $selector] { + set xfail_index [string first "xfail" $selector] + set xfail_selector [string range $selector $xfail_index end] + set target_selector [string range $selector 0 $xfail_index-1] + set target_selector [string trim $target_selector] + if { [dg-process-target-1 $target_selector] == "N" } { + return "N" + } + return [dg-process-target-1 $xfail_selector] + + } + return [dg-process-target-1 $selector] + } }