Hi!

On 2020-06-30T18:35:36+0200, I wrote:
> On 2020-06-22T11:32:46-0300, Alexandre Oliva <ol...@adacore.com> wrote:
>> --- /dev/null
>> +++ b/gcc/testsuite/lib/scanoffload.exp
>
>> +# Utility for scanning offloading dump output, used by libgomp.exp.
>
> ;-) Yeah, I was about to say that having this file in
> 'gcc/testsuite/lib/' seems to be a bit of an abstraction violation, given
> that...
>
>> +# Format an offload dump suffix given the offload target name in
>> +# OFFTGT and any suffix, probably empty, in SUFFIX.
>> +proc scoff-format { offtgt suffix } {
>> +    return ".x$offtgt.mkoffload$suffix"
>> +}
>> +
>> +# Wrapper for scan procs.
>> +# Argument 0 is the index of the argument to replace when calling
>> +# argument 1 with the remaining arguments.  Use end-1 or end or so.
>> +proc scoff { args } {
>> +    set idx [lindex $args 0]
>> +    set prc [lindex $args 1]
>> +    set args [lreplace $args 0 1]
>> +
>> +    global offload_target
>> +    if [info exists offload_target] {
>> +    set target $offload_target
>> +    if { "$target" != "disable" } {
>> +        eval $prc [lreplace $args $idx $idx "[scoff-format $target [lindex 
>> $args $idx]]"]
>> +    }
>> +    } else {
>> +    global offload_targets
>> +    foreach target [split $offload_targets ","] {
>> +        eval $prc [lreplace $args $idx $idx "[scoff-format $target [lindex 
>> $args $idx]]"]
>> +    }
>> +    }
>> +}
>
> ... only libgomp testing defines the 'offload_target', 'offload_targets'
> variables.  But anyway, it works, and we've got worse things in GCC.  ;-)

Actually, there is one problem.  To cure it, I've pushed commit
fdc9db25395e5a6e77069c04fe713f165a9c52a4 "[testsuite] Unset
'offload_target' after use" to master branch, see attached.


Grüße
 Thomas


-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander 
Walter
>From fdc9db25395e5a6e77069c04fe713f165a9c52a4 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <tho...@codesourcery.com>
Date: Wed, 1 Jul 2020 12:33:59 +0200
Subject: [PATCH] [testsuite] Unset 'offload_target' after use

..., so that we don't leak this into '*.exp' files running later.

This is relevant after commit efc16503ca10bc0e934e0bace5777500e4dc757a "handle
dumpbase in offloading, adjust testsuite" -- I was confused why in a
(simplified) testing sequence as follows:

  default 'libgomp.c/c.exp'
  default 'libgomp.oacc-c/c.exp'
  '-m32' 'libgomp.c/c.exp'
  '-m32' 'libgomp.oacc-c/c.exp'

..., the "'-m32' 'libgomp.c/c.exp'" variant would not execute any offloading
dump scanning.  The reason is that the "default 'libgomp.oacc-c/c.exp'" variant
ends with 'offload_target=disable' set, so that's what the "'-m32'
'libgomp.c/c.exp'" variant would then see, in particular
'gcc/testsuite/lib/scanoffload.exp:scoff'.

	libgomp/
	* testsuite/libgomp.oacc-c++/c++.exp: Unset 'offload_target' after
	use.
	* testsuite/libgomp.oacc-c/c.exp: Likewise.
	* testsuite/libgomp.oacc-fortran/fortran.exp: Likewise.
---
 libgomp/testsuite/libgomp.oacc-c++/c++.exp         | 1 +
 libgomp/testsuite/libgomp.oacc-c/c.exp             | 1 +
 libgomp/testsuite/libgomp.oacc-fortran/fortran.exp | 1 +
 3 files changed, 3 insertions(+)

diff --git a/libgomp/testsuite/libgomp.oacc-c++/c++.exp b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
index 7200ec19c47..42e0395f9a5 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/c++.exp
+++ b/libgomp/testsuite/libgomp.oacc-c++/c++.exp
@@ -149,6 +149,7 @@ if { $lang_test_file_found } {
 
 	gcc-dg-runtest $tests "$tagopt" "$libstdcxx_includes"
     }
+    unset offload_target
 } else {
     # Call this once, which placates the subsequent torture-finish.
     set-torture-options [list \
diff --git a/libgomp/testsuite/libgomp.oacc-c/c.exp b/libgomp/testsuite/libgomp.oacc-c/c.exp
index 48cbc980731..4bb2b2ac494 100644
--- a/libgomp/testsuite/libgomp.oacc-c/c.exp
+++ b/libgomp/testsuite/libgomp.oacc-c/c.exp
@@ -112,6 +112,7 @@ foreach offload_target [concat [split $offload_targets ","] "disable"] {
 
     gcc-dg-runtest $tests "$tagopt" ""
 }
+unset offload_target
 
 # All done.
 torture-finish
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp b/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
index d6079032505..7365b320668 100644
--- a/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
+++ b/libgomp/testsuite/libgomp.oacc-fortran/fortran.exp
@@ -121,6 +121,7 @@ if { $lang_test_file_found } {
 	# typically not the case for C/C++.
 	gfortran-dg-runtest $tests "$tagopt" ""
     }
+    unset offload_target
 }
 
 # All done.
-- 
2.17.1

Reply via email to