]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: Make profopt-execute also copy profile data for dg-additional-sources
authorJoseph Myers <josmyers@redhat.com>
Mon, 26 Jan 2026 16:49:29 +0000 (16:49 +0000)
committerJoseph Myers <josmyers@redhat.com>
Mon, 26 Jan 2026 16:49:29 +0000 (16:49 +0000)
Most gcc.dg/tree-prof tests work correctly in environments where .gcda
files from the first run need to be copied from the target, because
there is existing code in profopt-execute to do so.  A few tests using
dg-additional-sources fail because that code only copies the .gcda
file for the main test source file.  Add similar code to copy it for
any sources listed in dg-additional-sources as well.

The use of additional_sources_used is consistent with what
profopt-target-cleanup does.  It turns out to require the added call
to cleanup-after-saved-dg-test to avoid additional_sources_used
leaking from one test into the next.

Tested for x86_64-pc-linux-gnu to make sure native testing isn't
broken, and with cross to aarch64-linux.

* lib/profopt.exp (profopt-execute): Also copy profile data from
target for additional sources.  Call cleanup-after-saved-dg-test
before normal return.

gcc/testsuite/lib/profopt.exp

index 3188ba8a53485f58060307f8910c1eecc1051017..c9f5ae53d499fe757ef3a1cb328a68880ac41b2e 100644 (file)
@@ -312,6 +312,7 @@ proc profopt-execute { src } {
     global generate_final_code use_final_code
     global verbose
     global testname_with_flags
+    global additional_sources_used
 
     if ![info exists profile_option] {
         error "No profile option specified for first compile."
@@ -474,6 +475,19 @@ proc profopt-execute { src } {
                    set missing_file 1
                    fail "$testcase execution: file $bprefix$base.$ext does not exist, $option $profile_option"
                }
+               if [info exists additional_sources_used] {
+                   foreach srcfile $additional_sources_used {
+                       set add_basename [file tail $srcfile]
+                       set add_base [file rootname $add_basename]
+                       remote_upload target $tmpdir/$bprefix$add_base.$ext
+                       set files [glob -nocomplain $bprefix$add_base.$ext]
+                       if { $files == "" } {
+                           set status "fail"
+                           set missing_file 1
+                           fail "$testcase execution: file $bprefix$add_base.$ext does not exist, $option $profile_option"
+                       }
+                   }
+               }
            }
        }
         if { $missing_file == 0 } {
@@ -606,4 +620,5 @@ proc profopt-execute { src } {
        }
     }
     unset testname_with_flags
+    cleanup-after-saved-dg-test
 }