From patchwork Wed Nov 16 02:11:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 20661 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3049257wru; Tue, 15 Nov 2022 18:13:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf4GSsbebjvEeaYKXLJBmz3J1RryQ1m2n1BTjg8XFs5rBCp8J8SSFRkfrowyfFbv1FHVXmj1 X-Received: by 2002:a50:9503:0:b0:457:1edb:996c with SMTP id u3-20020a509503000000b004571edb996cmr17273404eda.363.1668564794797; Tue, 15 Nov 2022 18:13:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668564794; cv=none; d=google.com; s=arc-20160816; b=AgVie311EDZHZBotUf8R2RLEdU3+AMMJ/7txdLQmf+fh1XRKoXPH3ov+giYF5dpaFF lT3kB29fy/gBc5JDiy+S2W64zyUqXQlTStTDwtRoJZ1tWYX9BpqDvwfGYJpcevErU5HD 1D7IpZ2hflFp+t6lA9my4KppDGZ4H64i/7xEDfJeJlTEvTiM9DPK1uKAcSVDGKNmx6NH +UI5hk6MdXME7pUITYpXaHl/G16ZaGcKd8cmIWYacujyDDW7UjEBMQkUcd7tXp0cV9WR 6T/7yO2gymeGLerSwgBGkrE3W0M2/MHcMI5+vpSNsmFRrfuAZbPOD9m0rPec+xZzlzEE Xj2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:date:message-id :references:content-transfer-encoding:mime-version:subject :in-reply-to:cc:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=mjLmq9dp6oh/S7s2m2Vl5oRraF+bSt4DzPpq5P2rEnU=; b=OECpWSDLbnPnvSkO+yrSvYlqQfPlASFyH0OCQ8jKYGRkioHz6bgjoXnyiU9I1NarV7 26enDZsyeISnaFA/KXXJsrjc+FDQ4W9DIMnRDWUdKRUS/NBqZ/Bdo5Dbgvxtr9VWvsxf gXRZuxYqRx2R9KInBoZHc6ixBi1VqRZJCqJq7vEyeDY+0AbiT99DUG3+Wu7h0KmQF1lC TsAuaR9cxZ4vs/AITr2Nm1VUXOAmsztMJeNFlwUg3epuZmyqtgZwYYstN8K7JW/WJoz8 tZ8J1JxhHgEIe1DIK9b9b2NBmr9Zd6M5HMhwib4KLp/XBCm2fusUjeYigekBXD2hQ9z3 FJiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=olKfYTM9; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id q1-20020a17090676c100b0079e1916c11asi9699469ejn.703.2022.11.15.18.13.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 18:13:14 -0800 (PST) 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; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=olKfYTM9; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DAB083955626 for ; Wed, 16 Nov 2022 02:12:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DAB083955626 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668564762; bh=mjLmq9dp6oh/S7s2m2Vl5oRraF+bSt4DzPpq5P2rEnU=; h=To:CC:In-Reply-To:Subject:References:Date:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=olKfYTM9ZoYr09PB9pr/mlY+efO+Oka1fG4UjRpVW+Z53bFFjvbMH6AtYoTe7hURz 83EeAoRrThBKF+me7aGSO41YVnGhJbBQ/U6kh0JLeUuxpYMU7jB7LtPkvkxOWP3rNQ 3hwGMvD7LXgALtc1YapuRhwZbHPOdYDQN1iAIaUw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by sourceware.org (Postfix) with ESMTPS id 1B9023896C20 for ; Wed, 16 Nov 2022 02:11:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1B9023896C20 To: , Torbjorn SVENSSON CC: In-Reply-To: (message from Torbjorn SVENSSON via Gcc-patches on Mon, 12 Sep 2022 11:39:44 +0200) Subject: [PATCH] testsuite: Fix mistransformed gcov MIME-Version: 1.0 References: <20220909125624.2561867-1-torbjorn.svensson@foss.st.com> <662abb45-dad9-f0f7-4af6-940829d648a6@foss.st.com> <54513c03-1421-b480-fc6b-2229e811396b@foss.st.com> Message-ID: <20221116021154.4AE372042F@pchp3.se.axis.com> Date: Wed, 16 Nov 2022 03:11:54 +0100 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Hans-Peter Nilsson via Gcc-patches From: Hans-Peter Nilsson Reply-To: Hans-Peter Nilsson Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749616998278501354?= X-GMAIL-MSGID: =?utf-8?q?1749616998278501354?= How was r13-2619-g34b9a03353d3fd "gcov: Respect triplet when looking for gcov" tested? I'm having a hard time believing it was tested with a *cross-compiler* *in-build-tree*. I think it was only tested for the special-case of an installed cross-compiler; not even with a native build exercising the false branch (see patch), considering that a breaking typo ("}" vs "]") snuck by in the first revision, before commit. I guess reviewers forgot to ask that, but it's really on the submitter; it's a general requirement for patches to say how it was tested. Usually no more is needed than "tested with a cross-compiler for ..., no regressions" (implying running twice and comparing results before and after the patch). In this case, when adjusting test-framework bits, a little more care and mentioned details about how it was tested, would have been in order. It's likely it'd have shown that an uninstalled in-tree cross (an IMHO more expected case) wasn't tested, which that patch broke for the one gcov invocation that the testsuite does for cross-builds (IIUC). It can be said like this: I tested *this* patch as follows (all directory names below manually redacted), showing no regressions and fixing the regression for the in-tree cross build; For a native build (x86_64, Debian 11): - In the gcc build directory: make check RUNTESTFLAGS=gcov.exp - In an empty new directory after native installation in /pre. /gccsrc/top/contrib/test_installed --prefix=/pre gcov.exp - Also, for good measure (mentioned somewhere in the installation documentation) native: for tool in gcc g++ ; do env PATH=/pre/bin:$PATH runtest \ --tool $tool --srcdir=/gccsrc/top/gcc/testsuite gcov.exp; done For a cris-elf cross: - In the gcc build directory: make check 'RUNTESTFLAGS=--target_board=cris-sim gcov.exp' - In an empty new directory after installation in /pre. /gccsrc/top/contrib/test_installed --with-gcc=/pre/bin/cris-elf-gcc \ --with-g++=/pre/bin/cris-elf-g++ --with-gfortran=/pre/bin/cris-elf-gfortran \ --target=cris-elf --target_board=cris-sim gcov.exp Ok to commit? brgds, H-P PS. Beware that the proc name may be up for bikeshedding. ---- 8< -------- 8< -------- 8< -------- 8< ---- In commit r13-2619-g34b9a03353d3fd, [transform] was applied to all invocations of gcov, for both out-of-tree and in-tree testing. For in-tree cross builds, this means gcov was called as "/path/to/gccobj/gcc/target-tuple-gcov" gcov-pr94029.c which is incorrect, as it's there "/path/to/gccobj/gcc/gcov" until it's installed. This caused a testsuite failure, like: Running /x/gcc/gcc/testsuite/gcc.misc-tests/gcov.exp ... FAIL: gcc.misc-tests/gcov-pr94029.c gcov failed: spawn failed To avoid cumbersome conditionals, use a dedicated new helper function. gcc/testsuite: * lib/gcc-dg.exp (gcc-transform-out-of-tree): New proc. * g++.dg/gcov/gcov.exp, gcc.misc-tests/gcov.exp: Call gcc-transform-out-of-tree instead of transform. --- gcc/testsuite/g++.dg/gcov/gcov.exp | 4 ++-- gcc/testsuite/gcc.misc-tests/gcov.exp | 4 ++-- gcc/testsuite/lib/gcc-dg.exp | 13 +++++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/gcc/testsuite/g++.dg/gcov/gcov.exp b/gcc/testsuite/g++.dg/gcov/gcov.exp index 04e7a0164865..c9f20958836b 100644 --- a/gcc/testsuite/g++.dg/gcov/gcov.exp +++ b/gcc/testsuite/g++.dg/gcov/gcov.exp @@ -24,9 +24,9 @@ global GXX_UNDER_TEST # Find gcov in the same directory as $GXX_UNDER_TEST. if { ![is_remote host] && [string match "*/*" [lindex $GXX_UNDER_TEST 0]] } { - set GCOV [file dirname [lindex $GXX_UNDER_TEST 0]]/[transform gcov] + set GCOV [file dirname [lindex $GXX_UNDER_TEST 0]]/[gcc-transform-out-of-tree gcov] } else { - set GCOV [transform gcov] + set GCOV [gcc-transform-out-of-tree gcov] } # Initialize harness. diff --git a/gcc/testsuite/gcc.misc-tests/gcov.exp b/gcc/testsuite/gcc.misc-tests/gcov.exp index b8e9661aa537..90ceec46e0f0 100644 --- a/gcc/testsuite/gcc.misc-tests/gcov.exp +++ b/gcc/testsuite/gcc.misc-tests/gcov.exp @@ -24,9 +24,9 @@ global GCC_UNDER_TEST # For now find gcov in the same directory as $GCC_UNDER_TEST. if { ![is_remote host] && [string match "*/*" [lindex $GCC_UNDER_TEST 0]] } { - set GCOV [file dirname [lindex $GCC_UNDER_TEST 0]]/[transform gcov] + set GCOV [file dirname [lindex $GCC_UNDER_TEST 0]]/[gcc-transform-out-of-tree gcov] } else { - set GCOV [transform gcov] + set GCOV [gcc-transform-out-of-tree gcov] } # Initialize harness. diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp index 23ec038f41eb..2910c9ce0998 100644 --- a/gcc/testsuite/lib/gcc-dg.exp +++ b/gcc/testsuite/lib/gcc-dg.exp @@ -1429,5 +1429,18 @@ proc scan-symbol-not { args } { } } +# Transform a tool-name to its canonical-target-name by "transform" +# (which may return the original name for native targets) but only if +# testing out-of-tree. When in-tree, the tool is expected to be found +# by its original name, typically with some build-directory prefix +# prepended by the caller. +proc gcc-transform-out-of-tree { args } { + global TESTING_IN_BUILD_TREE + if { [info exists TESTING_IN_BUILD_TREE] } { + return $args; + } + return [transform $args] +} + set additional_prunes "" set dg_runtest_extra_prunes ""