diff mbox series

outputs.exp: skip @file -save-temps if target has -L or -I

Message ID 20210225051139.69B62203B3@pchp3.se.axis.com
State New
Headers show
Series outputs.exp: skip @file -save-temps if target has -L or -I | expand

Commit Message

Hans-Peter Nilsson Feb. 25, 2021, 5:11 a.m. UTC
The outputs.exp tests check what temporary files are created
and left behind with e.g. -save-temps.

Additional files are created in presence of @file option.
Adding an -I or -L option causes *another* temporary file to
appear.  I take it that's deliberate, as there are tests for
that behavior.

For native testing, the default test-framework baseboard
file unix.exp doesn't add any -I or -L options and all tests
pass.  For a newlib target however, you'll have a couple of
-L options (see the nopts handling in outputs.exp), leading
to (cris-elf with --target_board=cris-sim):

Running /x/gcc/gcc/testsuite/gcc.misc-tests/outputs.exp ...
FAIL: outputs exe savetmp namedb: extra
outputs.args.1
FAIL: outputs exe savetmp named2: extra
outputs.args.1
FAIL: outputs exe savetmp named2: extra
outputs.args.3
FAIL: outputs lto sing unnamed: extra
a.args.1

The failing tests are among the actual tests that check the
behavior of @file, and are confused by the additional -L.

Identify presence of -I or -L from the test framework and
skip those tests.

Tested cris-elf and x86_64-pc-linux-gnu.

Ok to commit?

gcc/testsuite:
	* gcc.misc-tests/outputs.exp: Skip @file -save-temps
	tests if target test-framework has -L or -I options.
---
 gcc/testsuite/gcc.misc-tests/outputs.exp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Jeff Law March 2, 2021, 10:38 p.m. UTC | #1
On 2/24/21 10:11 PM, Hans-Peter Nilsson via Gcc-patches wrote:
> The outputs.exp tests check what temporary files are created
> and left behind with e.g. -save-temps.
>
> Additional files are created in presence of @file option.
> Adding an -I or -L option causes *another* temporary file to
> appear.  I take it that's deliberate, as there are tests for
> that behavior.
>
> For native testing, the default test-framework baseboard
> file unix.exp doesn't add any -I or -L options and all tests
> pass.  For a newlib target however, you'll have a couple of
> -L options (see the nopts handling in outputs.exp), leading
> to (cris-elf with --target_board=cris-sim):
>
> Running /x/gcc/gcc/testsuite/gcc.misc-tests/outputs.exp ...
> FAIL: outputs exe savetmp namedb: extra
> outputs.args.1
> FAIL: outputs exe savetmp named2: extra
> outputs.args.1
> FAIL: outputs exe savetmp named2: extra
> outputs.args.3
> FAIL: outputs lto sing unnamed: extra
> a.args.1
>
> The failing tests are among the actual tests that check the
> behavior of @file, and are confused by the additional -L.
>
> Identify presence of -I or -L from the test framework and
> skip those tests.
>
> Tested cris-elf and x86_64-pc-linux-gnu.
>
> Ok to commit?
>
> gcc/testsuite:
> 	* gcc.misc-tests/outputs.exp: Skip @file -save-temps
> 	tests if target test-framework has -L or -I options.
OK
jeff
Alexandre Oliva March 3, 2021, 1:26 p.m. UTC | #2
On Feb 25, 2021, Hans-Peter Nilsson <hp@axis.com> wrote:

> Additional files are created in presence of @file option.

Oh, wow.  I hope nobody uses @file in target board files ;-)

> gcc/testsuite:
> 	* gcc.misc-tests/outputs.exp: Skip @file -save-temps
> 	tests if target test-framework has -L or -I options.

Thanks, this looks reasonable.

I suppose it might be possible to record the presence of -I and -L flags
separately, and adjust the @file tests so as to conditionally expect
extra files where they'd appear, but I don't see that this would
increase test coverage, so ISTM that would be a pointless effort.  So
we're good.  Thanks!
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.misc-tests/outputs.exp b/gcc/testsuite/gcc.misc-tests/outputs.exp
index 4d904bde31d5..ebd61448bfdd 100644
--- a/gcc/testsuite/gcc.misc-tests/outputs.exp
+++ b/gcc/testsuite/gcc.misc-tests/outputs.exp
@@ -57,10 +57,18 @@  set gld [check_effective_target_gld]
 # We do not compile to an executable, because that requires naming an output.
 set link_options ""
 set dest [target_info name]
+set skip_atsave 0
 foreach i { ldflags libs ldscript } {
     if {[board_info $dest exists $i]} {
 	set opts [board_info $dest $i]
 	set nopts [gcc_adjust_linker_flags_list $opts]
+
+	# Options -I<X> and -L<X> affect the behavior of @files
+	# wrt. temporary files.  Skip @file -save-temps tests if we
+	# have any of them in the board-flags.
+	if { [string match "* -\[LI\]*" " $nopts"]} {
+	    set skip_atsave 1
+	}
 	foreach opt $nopts {
 	    append link_options " additional_flags=$opt"
 	}
@@ -298,10 +306,12 @@  outest "$b exe savetmp namedb" $sing "-o $b.exe -save-temps" {} {{--0.i --0.s --
 outest "$b exe savetmp named2" $mult "-o $b.exe -save-temps" {} {{--1.i --1.s --1.o --2.i --2.s --2.o .exe}}
 
 # Additional files are created when an @file is used
+if !$skip_atsave {
 outest "$b exe savetmp namedb" $sing "@/dev/null -o $b.exe -save-temps" {} {{--0.i --0.s --0.o .args.0 !!$gld .ld1_args !0 .exe}}
 outest "$b exe savetmp named2" $mult "@/dev/null -o $b.exe -save-temps" {} {{--1.i --1.s --1.o --2.i --2.s --2.o .args.0 !!$gld .ld1_args !0 .exe}}
 outest "$b exe savetmp named2" $mult "@/dev/null -I dummy -o $b.exe -save-temps" {} {{--1.i --1.s --1.o --2.i --2.s --2.o -args.0 -args.1 .args.2 !!$gld .ld1_args !0 .exe}}
 outest "$b exe savetmp named2" $mult "@/dev/null -I dummy -L dummy -o $b.exe -save-temps" {} {{--1.i --1.s --1.o --2.i --2.s --2.o -args.0 -args.1 .args.2 .args.3 !!$gld .ld1_args !0 .exe}}
+}
 
 # Setting the main output to a dir selects it as the default aux&dump
 # location.
@@ -657,8 +667,10 @@  outest "$b lto sing named" $sing "-o $b.exe -O2 -flto -fno-use-linker-plugin -fl
 outest "$b lto mult named" $mult "-o $b.exe -O2 -flto -fno-use-linker-plugin -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {} {{--1.c.???i.icf --1.c.???r.final --2.c.???i.icf --2.c.???r.final .wpa.???i.icf .ltrans0.ltrans.???r.final .ltrans0.ltrans.su .exe}}
 outest "$b lto sing nameddir" $sing "-o dir/$b.exe -O2 -flto -fno-use-linker-plugin -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{--0.c.???i.icf --0.c.???r.final .wpa.???i.icf .ltrans0.ltrans.???r.final .ltrans0.ltrans.su .exe} {}}
 outest "$b lto mult nameddir" $mult "-o dir/$b.exe -O2 -flto -fno-use-linker-plugin -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage" {dir/} {{--1.c.???i.icf --1.c.???r.final --2.c.???i.icf --2.c.???r.final .wpa.???i.icf .ltrans0.ltrans.???r.final .ltrans0.ltrans.su .exe} {}}
+if !$skip_atsave {
 outest "$b lto sing unnamed" $sing "@/dev/null -O2 -flto -fno-use-linker-plugin -flto-partition=one -fdump-ipa-icf-optimized -fdump-rtl-final -fstack-usage -save-temps $oaout" {} {{a--0.c.???i.icf a--0.c.???r.final a.wpa.???i.icf a.ltrans0.ltrans.???r.final a.ltrans0.ltrans.su a--0.o a--0.s a--0.i a.ltrans0.o a.ltrans.out a.ltrans0.ltrans.o a.ltrans0.ltrans_args a.args.0 a.ltrans0.ltrans.s a.wpa.args.0 a.lto_args a.ld1_args a.ltrans_args a.ltrans0.ltrans.args.0 a.ld_args $aout}}
 }
+}
 
 # -dumpbase without -dumpdir.  The trailing dumppfx dash after it is
 # combined with dumpbase turns into a period when passed to lto as