]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: Add support for GCOV_UNDER_TEST
authorChristophe Lyon <christophe.lyon@linaro.org>
Tue, 1 Apr 2025 16:22:10 +0000 (16:22 +0000)
committerChristophe Lyon <christophe.lyon@linaro.org>
Tue, 22 Apr 2025 10:13:51 +0000 (10:13 +0000)
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.

gcc/testsuite/g++.dg/gcov/gcov.exp
gcc/testsuite/gcc.misc-tests/gcov.exp
gcc/testsuite/gdc.dg/gcov.exp
gcc/testsuite/gnat.dg/gcov/gcov.exp

index 50f60c4a011535d33c20856c6c3f3289098a2ab7..04c7c956c362dadcfb8c18e3e1fcd392f7c9bff3 100644 (file)
@@ -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.
index c8f20e1e70eae5d3da20e48c55da24c1d2586a14..4d427c8b8de819b1e110f3b26adc87c491c06541 100644 (file)
@@ -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.
index a65d0000d34db63f6275e058494a8fcf03c57d38..3f0234e9f2f71de5208a8227bf50c1a06fdd05a6 100644 (file)
@@ -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.
index 4fa887d5bade96a6319f0bf66500a69a5f0a9975..031914ac84911eb2bf732a10a2dd0c2ddb8a7b51 100644 (file)
@@ -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.