From patchwork Fri Jan 17 22:07:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 1225035 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-517629-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=yHI8pZ/d; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=drjd+evn; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47zwDQ58pGz9s1x for ; Sat, 18 Jan 2020 09:08:06 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=GEUw2Zrv2EW3kjPa Mn6VgFwLMbp0tyWl7t4Hd5ABWJUF8ZP5+2fb30vMF6p/mcz5Td7wZrRSygxWqTWc OzjdD437YvQYHNBpTY6uTKQB/kpmqZQtD8zkmLYs9BetKllRbwwVvtGFliDZRVvn wsxNlguDouS4J2KNHebsJnI7Upo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=Mz/HsEno5fQV7ELr+U9s0n sgPYI=; b=yHI8pZ/dkl0TQE9i0XurraoyC4tikChiFi9agC303mh8xAhtc70L66 dXCEq/ljwd4ioAHXlT7RjM+9fFBss1aAELv3mvD7Gw8vtyOgoiU59p5unwhhv5/u iFOR5mjCTSt1dfKuFljH3eb5LGaUQVNR+6BWEyz2jME05BYLALZ9Q= Received: (qmail 115013 invoked by alias); 17 Jan 2020 22:07:59 -0000 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 Received: (qmail 115001 invoked by uid 89); 17 Jan 2020 22:07:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=major.minor, majorminor X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-1.mimecast.com (HELO us-smtp-1.mimecast.com) (207.211.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 17 Jan 2020 22:07:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579298876; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uLXOgLUq/wQxIcISRoCo5z1FpuaafpVbBVopVm35js8=; b=drjd+evn5CPDcgqduC+vh+vU02S9aAEN6OLAtR4/ha3K1smeBlosvfbbUtJsyu03F3IpCj 3OTxiP2197CMEbXTcfCQYw1gsduyORoUkk3ArXpZ9TLhvctWKjVLEzG1LyI1TD6POQDDTk kgpkkZBZY3r69TemDhk//dTZqOCgPKY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-13-fxkIX32SO9--p0-SelpNHw-1; Fri, 17 Jan 2020 17:07:54 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 85D08108592A for ; Fri, 17 Jan 2020 22:07:53 +0000 (UTC) Received: from t470.redhat.com (ovpn-117-41.phx2.redhat.com [10.3.117.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21CD984773; Fri, 17 Jan 2020 22:07:53 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH] RFC: testsuite: add minimium version to dg-require-dot (PR analyzer/93293) Date: Fri, 17 Jan 2020 17:07:51 -0500 Message-Id: <20200117220751.11230-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-IsSubscribed: yes I ran into difficulties with the Graphviz format changing from under me during an upgrade, where the new version of "dot" would reject .dot files generated by the analyzer. The analyzer testsuite has a dot-output.c test that attempts to check that the generated .dot can be handled by dot, with a dg-require-dot gating the test. Unfortunately older versions of dot can't handle the newer generated output, leading to FAILs from the test. (I'm also not convinced that newer graphviz versions can always handle the output from the other passes) I'd like to automatically verify that the dot output is actually viewable. The following patch attempts to add version-checking to dg-require-dot, rejecting the test as unsupported if dot on the host is earlier than version 2.40 Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu, FWIW. But presumably I should do some kind of feature-testing rather than version-testing. I don't think I can embed the .dot input into a dg directive. Perhaps have dg-require-dot be passed a relative path to a feature-test .dot file in the testsuite source directory, and if it can handle that, then dg-require-dot returns 1 and allows the test to occur? Thoughts? gcc/testsuite/ChangeLog: PR analyzer/93293 * gcc.dg/analyzer/dot-output.c (dg-require-dot): Add "2.40" to argument. * lib/target-supports-dg.exp (dg-require-dot): Add argument. * lib/target-supports.exp (parse_version_string): New. (check_dot_available): Add args and parse them for a minimum required version. Attempt to parse the output of dot -V. Compare them. --- gcc/testsuite/gcc.dg/analyzer/dot-output.c | 2 +- gcc/testsuite/lib/target-supports-dg.exp | 5 +- gcc/testsuite/lib/target-supports.exp | 67 +++++++++++++++++++++- 3 files changed, 68 insertions(+), 6 deletions(-) diff --git a/gcc/testsuite/gcc.dg/analyzer/dot-output.c b/gcc/testsuite/gcc.dg/analyzer/dot-output.c index 25cb31f2d89..628bbda8d34 100644 --- a/gcc/testsuite/gcc.dg/analyzer/dot-output.c +++ b/gcc/testsuite/gcc.dg/analyzer/dot-output.c @@ -1,7 +1,7 @@ /* Verify that the various .dot output files from the analyzer are readable by .dot. */ -/* { dg-require-dot "" } */ +/* { dg-require-dot "2.40" } */ /* { dg-additional-options "-fdump-analyzer-callgraph -fdump-analyzer-exploded-graph -fdump-analyzer-state-purge -fdump-analyzer-supergraph" } */ #include diff --git a/gcc/testsuite/lib/target-supports-dg.exp b/gcc/testsuite/lib/target-supports-dg.exp index 2a21424b890..8bee84975cb 100644 --- a/gcc/testsuite/lib/target-supports-dg.exp +++ b/gcc/testsuite/lib/target-supports-dg.exp @@ -180,11 +180,12 @@ proc dg-require-iconv { args } { } } -# If this host does not have "dot", skip this test. +# If this host does not have "dot", with a minimum version +# of at least REQ_MAJOR.REQ_MINOR, skip this test. proc dg-require-dot { args } { verbose "dg-require-dot" 2 - if { ![ check_dot_available ] } { + if { ![ check_dot_available $args ] } { upvar dg-do-what dg-do-what set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"] } diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 79166986c77..b527d30e8a7 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -514,17 +514,78 @@ proc check_gc_sections_available { } { }] } -# Returns 1 if "dot" is supported on the host. +# Attempt to parse STR as a major.minor pair. +# Return in list form as a major.minor pair, or throw an exception + +proc parse_version_string { str } { + if { [regexp {([0-9]*)\.([0-9]*)} $str match major minor] } { + verbose "major: $major" 3 + verbose "minor: $minor" 3 + lappend result $major $minor + return $result + } else { + error "unable to parse version $str" + } +} -proc check_dot_available { } { +# Returns 1 if "dot" is supported on the host, with a minimum version +# of at least "REQ_MAJOR.REQ_MINOR" + +proc check_dot_available { args } { verbose "check_dot_available" 2 + verbose " args: $args" 3 + set req_version_str [lindex [lindex $args 0] 1] + verbose " req_version_str: $req_version_str" 3 + if { [catch { set req_version [parse_version_string $req_version_str] } ] } { + verbose "unable to determine required dot version" 2 + return 0 + } else { + set req_major [lindex $req_version 0] + set req_minor [lindex $req_version 1] + } + verbose " req_version: $req_version" 3 + verbose " req_major: $req_major" 3 + verbose " req_minor: $req_minor" 3 set status [remote_exec host "dot" "-V"] verbose " status: $status" 2 if { [lindex $status 0] != 0 } { return 0 } - return 1 + set dot_output [lindex $status 1] + verbose " dot_output: $dot_output" 3 + + # Attempt to parse the dot version into major and minor components. + # Expect a string like "dot - graphviz version 2.40.1 (0)". + if { [catch { set version [parse_version_string $dot_output] } ] } { + verbose "unable to determine dot version" 2 + return 0 + } else { + set major [lindex $version 0] + set minor [lindex $version 1] + } + verbose " version: $version" 3 + verbose " major: $major" 3 + verbose " minor: $minor" 3 + + if { [expr $major > $req_major] } { + # Major release beats REQ_MAJOR: no need to check minor + verbose "dot major version ($major) exceeds minimum major version ($req_major)" 3 + return 1 + } elseif { [expr $major == $req_major] } { + if { [expr $minor >= $req_minor] } { + verbose "dot minor version ($minor) exceeds minimum major version ($req_minor)" 3 + return 1 + } else { + # Minor release too low + verbose "dot version ($major.$minor) is below minimum ($req_major.$req_minor)" 2 + return 0 + } + } else { + # Major release too low + verbose "dot version ($major.$minor) is below minimum ($req_major.$req_minor)" 2 + return 0 + } } # Return 1 if according to target_info struct and explicit target list