https://gcc.gnu.org/g:dd3dfa3790f22bfcee20d869aefea5886f94346b

commit r16-71-gdd3dfa3790f22bfcee20d869aefea5886f94346b
Author: Christophe Lyon <christophe.l...@linaro.org>
Date:   Tue Apr 1 16:22:10 2025 +0000

    testsuite: Add support for GCOV_UNDER_TEST
    
    After commit r15-8947-g8ed2d5d219e999, which added new tests using
    gcov, the CI noticed failures because it was calling 'gcov' instead of
    $target-gcov.
    
    This is because the CI scripts override GXX_UNDER_TEST, but still run
    the testsuite in-tree, and gcc-transform-out-of-tree only depends on
    TESTING_IN_BUILD_TREE but the definition of GCOV uses GCC_UNDER_TEST,
    GXX_UNDER_TEST or GDC_UNDER_TEST (assuming their default values when
    TESTING_IN_BUILD_TREE).
    
    To handle such a case, this patch adds support for a new variable,
    GCOV_UNDER_TEST, which overrides the current behavior if defined, and
    has an effect similar to overriding GCC_UNDER_TEST etc...
    
    Unfortunately, the change needs to be duplicated in several places,
    which use either GCC_UNDER_TEST, GXX_UNDER_TEST or GDC_UNDER_TEST.
    
    Tested g++.dg/gcov/gcov.exp and now g++.dg/gcov/gcov-22.C passes
    (calling <installdir>/bin/$target-gcov as instructed by the CI
    scripts).  No change observed on gcc.misc-tests/gcov.exp, and I could
    not test gdc.dg/gcov.exp and gnat.dg/gcov/gcov.exp.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/gcov/gcov.exp: Handle GCOV_UNDER_TEST.
            * gcc.misc-tests/gcov.exp: Likewise.
            * gdc.dg/gcov.exp: Likewise.
            * gnat.dg/gcov/gcov.exp: Likewise.

Diff:
---
 gcc/testsuite/g++.dg/gcov/gcov.exp    | 15 +++++++++++----
 gcc/testsuite/gcc.misc-tests/gcov.exp | 15 +++++++++++----
 gcc/testsuite/gdc.dg/gcov.exp         | 15 +++++++++++----
 gcc/testsuite/gnat.dg/gcov/gcov.exp   | 15 +++++++++++----
 4 files changed, 44 insertions(+), 16 deletions(-)

diff --git a/gcc/testsuite/g++.dg/gcov/gcov.exp 
b/gcc/testsuite/g++.dg/gcov/gcov.exp
index 50f60c4a0115..04c7c956c362 100644
--- a/gcc/testsuite/g++.dg/gcov/gcov.exp
+++ b/gcc/testsuite/g++.dg/gcov/gcov.exp
@@ -21,12 +21,19 @@ load_lib g++-dg.exp
 load_lib gcov.exp
 
 global GXX_UNDER_TEST
+global GCOV_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]]/[gcc-transform-out-of-tree gcov]
+# Find gcov in the same directory as $GXX_UNDER_TEST, unless
+# GCOV_UNDER_TEST is defined.
+
+if ![info exists GCOV_UNDER_TEST] {
+    if { ![is_remote host] && [string match "*/*" [lindex $GXX_UNDER_TEST 0]] 
} {
+       set GCOV [file dirname [lindex $GXX_UNDER_TEST 
0]]/[gcc-transform-out-of-tree gcov]
+    } else {
+       set GCOV [gcc-transform-out-of-tree gcov]
+    }
 } else {
-    set GCOV [gcc-transform-out-of-tree gcov]
+    set GCOV $GCOV_UNDER_TEST
 }
 
 # Initialize harness.
diff --git a/gcc/testsuite/gcc.misc-tests/gcov.exp 
b/gcc/testsuite/gcc.misc-tests/gcov.exp
index c8f20e1e70ea..4d427c8b8de8 100644
--- a/gcc/testsuite/gcc.misc-tests/gcov.exp
+++ b/gcc/testsuite/gcc.misc-tests/gcov.exp
@@ -21,12 +21,19 @@ load_lib gcc-dg.exp
 load_lib gcov.exp
 
 global GCC_UNDER_TEST
+global GCOV_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]]/[gcc-transform-out-of-tree gcov]
+# For now find gcov in the same directory as $GCC_UNDER_TEST, unless
+# GCOV_UNDER_TEST is defined.
+
+if ![info exists GCOV_UNDER_TEST] {
+    if { ![is_remote host] && [string match "*/*" [lindex $GCC_UNDER_TEST 0]] 
} {
+       set GCOV [file dirname [lindex $GCC_UNDER_TEST 
0]]/[gcc-transform-out-of-tree gcov]
+    } else {
+       set GCOV [gcc-transform-out-of-tree gcov]
+    }
 } else {
-    set GCOV [gcc-transform-out-of-tree gcov]
+    set GCOV $GCOV_UNDER_TEST
 }
 
 # Initialize harness.
diff --git a/gcc/testsuite/gdc.dg/gcov.exp b/gcc/testsuite/gdc.dg/gcov.exp
index a65d0000d34d..3f0234e9f2f7 100644
--- a/gcc/testsuite/gdc.dg/gcov.exp
+++ b/gcc/testsuite/gdc.dg/gcov.exp
@@ -21,12 +21,19 @@ load_lib gdc-dg.exp
 load_lib gcov.exp
 
 global GDC_UNDER_TEST
+global GCOV_UNDER_TEST
 
-# For now find gcov in the same directory as $GDC_UNDER_TEST.
-if { ![is_remote host] && [string match "*/*" [lindex $GDC_UNDER_TEST 0]] } {
-    set GCOV [file dirname [lindex $GDC_UNDER_TEST 
0]]/[gcc-transform-out-of-tree gcov]
+# For now find gcov in the same directory as $GDC_UNDER_TEST, unless
+# GCOV_UNDER_TEST is defined.
+
+if ![info exists GCOV_UNDER_TEST] {
+    if { ![is_remote host] && [string match "*/*" [lindex $GDC_UNDER_TEST 0]] 
} {
+       set GCOV [file dirname [lindex $GDC_UNDER_TEST 
0]]/[gcc-transform-out-of-tree gcov]
+    } else {
+       set GCOV [gcc-transform-out-of-tree gcov]
+    }
 } else {
-    set GCOV [gcc-transform-out-of-tree gcov]
+    set GCOV $GCOV_UNDER_TEST
 }
 
 # Initialize harness.
diff --git a/gcc/testsuite/gnat.dg/gcov/gcov.exp 
b/gcc/testsuite/gnat.dg/gcov/gcov.exp
index 4fa887d5bade..031914ac8491 100644
--- a/gcc/testsuite/gnat.dg/gcov/gcov.exp
+++ b/gcc/testsuite/gnat.dg/gcov/gcov.exp
@@ -21,12 +21,19 @@ load_lib gnat-dg.exp
 load_lib gcov.exp
 
 global GCC_UNDER_TEST
+global GCOV_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]]/gcov
+# For now find gcov in the same directory as $GCC_UNDER_TEST, unless
+# GCOV_UNDER_TEST is defined.
+
+if ![info exists GCOV_UNDER_TEST] {
+    if { ![is_remote host] && [string match "*/*" [lindex $GCC_UNDER_TEST 0]] 
} {
+       set GCOV [file dirname [lindex $GCC_UNDER_TEST 0]]/gcov
+    } else {
+       set GCOV gcov
+    }
 } else {
-    set GCOV gcov
+    set GCOV $GCOV_UNDER_TEST
 }
 
 # Initialize harness.

Reply via email to