From patchwork Thu Aug 1 00:51:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 1967371 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=UThhVVbS; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WZ9S26Pj2z1ybX for ; Thu, 1 Aug 2024 10:53:06 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1AC38385C6C3 for ; Thu, 1 Aug 2024 00:53:05 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id C77D13858420 for ; Thu, 1 Aug 2024 00:51:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C77D13858420 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C77D13858420 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722473486; cv=none; b=ZleDWHnKLiI+EU3wWZH1YW/Flja7sNSIWf05V86ReaKDUudZFb2zjen4PZWHZd2g1muoAvi1K0zsY+aHxV5n82Hz3E62/u+FmfEoCA+psUXzoUwGCNUxbK3q7NpC9SyqIBc7Y4Z6F8d3cyCjtDzxHGgO7vCsUZStYpk653TWkmg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722473486; c=relaxed/simple; bh=N3Z81Zm8+pSMrJUV27SjnR7QTN3NViHYCj6kLGgBTI8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=oP04+ufbr2R0mPrx6UgkoggFdYR0VjX3FAASEb1uZavfgIneW6YJIvwY07k4/yBL5mD7znRPkxHM6egTUih4bHUkl7psVA38r28mq3gDGGSuxLiJJ3I1NbpUGOUL5F93skKOsSZke0/yl5X/cIyKSNZh4vzTwwRErOA2aDsrYJA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722473482; 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=P/W3ps+2aqHx+0cOkPdWlUaCwdhMvabRezH4mM318hM=; b=UThhVVbSLLGnPAtvTR5bE6mN0NlU1XsxkdRAqVSfwLV6xYVNB7k+JMeM837CdLBaODh3Ox cFA2xRVufTrHOlzs+8uiqbVL7tZE49gbzh1Babe6Zk6hz5W1odMDzHHxRSSSp+vtBk+0Z3 h53Uxy3QC/0bMuyW5Qz51Qm+4QgFq5o= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-370-pCDgewI-OA2A3hLw2DEIVA-1; Wed, 31 Jul 2024 20:51:18 -0400 X-MC-Unique: pCDgewI-OA2A3hLw2DEIVA-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 315AE1955F40 for ; Thu, 1 Aug 2024 00:51:17 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.22.33.183]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2B66F1955E80; Thu, 1 Aug 2024 00:51:16 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [pushed] testsuite: split out parts of jit.dg/jit.exp into a new lib/valgrind.exp Date: Wed, 31 Jul 2024 20:51:14 -0400 Message-Id: <20240801005114.1003918-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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~incoming=patchwork.ozlabs.org@gcc.gnu.org I want to reuse some of the support for valgrind in jit.exp in my upcoming testsuite for https://gcc.gnu.org/wiki/libdiagnostics so this patch splits that out into a valgrind.exp. No functional change intended. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r15-2468-g64fbaf36a3834c. gcc/testsuite/ChangeLog: * jit.dg/jit.exp: Add load_lib valgrind.exp. (proc report_leak): Move to valgrind.exp, and add argument leak_report_function rather than hardcoding xfail. (parse_valgrind_logfile): Likewise. (fixed_host_execute): Pass xfail to parse_valgrind_logfile. * lib/valgrind.exp: New file, based on the above. Signed-off-by: David Malcolm --- gcc/testsuite/jit.dg/jit.exp | 47 +++------------------------ gcc/testsuite/lib/valgrind.exp | 58 ++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 43 deletions(-) create mode 100644 gcc/testsuite/lib/valgrind.exp diff --git a/gcc/testsuite/jit.dg/jit.exp b/gcc/testsuite/jit.dg/jit.exp index 893ff5f6dd0..57b133b6d8c 100644 --- a/gcc/testsuite/jit.dg/jit.exp +++ b/gcc/testsuite/jit.dg/jit.exp @@ -38,6 +38,7 @@ load_lib gcc.exp load_lib g++.exp load_lib dejagnu.exp load_lib target-supports-dg.exp +load_lib valgrind.exp # Skip these tests for targets that don't support -lgccjit if { ![check_effective_target_lgccjit] } { @@ -47,48 +48,6 @@ if { ![check_effective_target_lgccjit] } { # The default do-what keyword. set dg-do-what-default compile -# Look for lines of the form: -# definitely lost: 11,316 bytes in 235 blocks -# indirectly lost: 352 bytes in 4 blocks -# Ideally these would report zero bytes lost (which is a PASS); -# for now, report non-zero leaks as XFAILs. -proc report_leak {kind name logfile line} { - set match [regexp "$kind lost: .*" $line result] - if $match { - verbose "Saw \"$result\" within \"$line\"" 4 - # Extract bytes and blocks. - # These can contain commas as well as numerals, - # but we only care about whether we have zero. - regexp "$kind lost: (.+) bytes in (.+) blocks" \ - $result -> bytes blocks - verbose "bytes: '$bytes'" 4 - verbose "blocks: '$blocks'" 4 - if { $bytes == 0 } { - pass "$name: $logfile: $result" - } else { - xfail "$name: $logfile: $result" - } - } -} - -proc parse_valgrind_logfile {name logfile} { - verbose "parse_valgrind_logfile: $logfile" 2 - if [catch {set f [open $logfile]}] { - fail "$name: unable to read $logfile" - return - } - - while { [gets $f line] >= 0 } { - # Strip off the PID prefix e.g. ==7675== - set line [regsub "==\[0-9\]*== " $line ""] - verbose $line 2 - - report_leak "definitely" $name $logfile $line - report_leak "indirectly" $name $logfile $line - } - close $f -} - # Given WRES, the result from "wait", issue a PASS # if the spawnee exited cleanly, or a FAIL for various kinds of # unexpected exits. @@ -327,7 +286,9 @@ proc fixed_host_execute {args} { if $run_under_valgrind { upvar 2 name name - parse_valgrind_logfile $name $valgrind_logfile + # Use xfail to report leaks, as libgccjit isn't yet clean of + # memory leaks (PR jit/63854) + parse_valgrind_logfile $name $valgrind_logfile xfail } # force a close of the executable to be safe. diff --git a/gcc/testsuite/lib/valgrind.exp b/gcc/testsuite/lib/valgrind.exp new file mode 100644 index 00000000000..7d4f7ce51da --- /dev/null +++ b/gcc/testsuite/lib/valgrind.exp @@ -0,0 +1,58 @@ +# Copyright (C) 2014-2024 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +# Look for lines of the form: +# definitely lost: 11,316 bytes in 235 blocks +# indirectly lost: 352 bytes in 4 blocks +# Report zero bytes lost as a a PASS. +# Use LEAK_REPORT_FUNCTION to report non-zero bytes lost (either fail or xfail) + +proc report_leak {kind name logfile line leak_report_function} { + set match [regexp "$kind lost: .*" $line result] + if $match { + verbose "Saw \"$result\" within \"$line\"" 4 + # Extract bytes and blocks. + # These can contain commas as well as numerals, + # but we only care about whether we have zero. + regexp "$kind lost: (.+) bytes in (.+) blocks" \ + $result -> bytes blocks + verbose "bytes: '$bytes'" 4 + verbose "blocks: '$blocks'" 4 + if { $bytes == 0 } { + pass "$name: $logfile: $result" + } else { + $leak_report_function "$name: $logfile: $result" + } + } +} + +proc parse_valgrind_logfile {name logfile leak_report_function} { + verbose "parse_valgrind_logfile: $logfile" 2 + if [catch {set f [open $logfile]}] { + fail "$name: unable to read $logfile" + return + } + + while { [gets $f line] >= 0 } { + # Strip off the PID prefix e.g. ==7675== + set line [regsub "==\[0-9\]*== " $line ""] + verbose $line 2 + + report_leak "definitely" $name $logfile $line $leak_report_function + report_leak "indirectly" $name $logfile $line $leak_report_function + } + close $f +}