1 # Copyright
(C
) 1997-2016 Free Software Foundation
, Inc.
3 # This
program is free software
; you can redistribute it and
/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation
; either version
3 of the License
, or
6 #
(at your option
) any later version.
8 # This
program is distributed in the hope that it will be useful
,
9 # but WITHOUT
ANY WARRANTY
; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License
for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with GCC
; see the file COPYING3.
If not see
15 #
<http
://www.gnu.org
/licenses
/>.
18 load_lib file
-format.exp
19 load_lib target
-supports.exp
20 load_lib target
-supports
-dg.exp
26 load_lib timeout
-dg.exp
29 load_lib target
-libpath.exp
30 load_lib torture
-options.exp
31 load_lib fortran
-modules.exp
32 load_lib multiline.exp
34 # We
set LC_ALL and LANG to C so that we
get the same error messages as expected.
38 # Many hosts now default to a non
-ASCII C locale
, however
, so
39 # they can
set a
charset encoding here
if they need.
40 if { [ishost
"*-*-cygwin*"] } {
46 if ![info exists GCC_UNDER_TEST
] {
47 set GCC_UNDER_TEST
"[find_gcc]"
50 # This file may be sourced
, so don
't override environment settings
51 # that have been previously setup.
52 if { $orig_environment_saved == 0 } {
53 append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
54 set_ld_library_path_env_vars
57 # Some torture-options cause intermediate code output, unusable for
58 # testing using e.g. scan-assembler. In this variable are the options
59 # how to force it, when needed.
60 global gcc_force_conventional_output
61 set gcc_force_conventional_output ""
63 set LTO_TORTURE_OPTIONS ""
64 if [info exists TORTURE_OPTIONS] {
65 set DG_TORTURE_OPTIONS $TORTURE_OPTIONS
67 # It is theoretically beneficial to group all of the O2/O3 options together,
68 # as in many cases the compiler will generate identical executables for
69 # all of them--and the c-torture testsuite will skip testing identical
70 # executables multiple times.
71 # Also note that -finline-functions is explicitly included in one of the
72 # items below, even though -O3 is also specified, because some ports may
73 # choose to disable inlining functions by default, even when optimizing.
74 set DG_TORTURE_OPTIONS [list \
78 { -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions } \
82 if [check_effective_target_lto] {
83 # When having plugin test both slim and fat LTO and plugin/nonplugin
85 if [check_linker_plugin_available] {
86 set LTO_TORTURE_OPTIONS [list \
87 { -O2 -flto -fno-use-linker-plugin -flto-partition=none } \
88 { -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects }
91 set LTO_TORTURE_OPTIONS [list \
92 { -O2 -flto -flto-partition=none } \
96 set gcc_force_conventional_output "-ffat-lto-objects"
100 if [info exists ADDITIONAL_TORTURE_OPTIONS] {
101 set DG_TORTURE_OPTIONS \
102 [concat $DG_TORTURE_OPTIONS $ADDITIONAL_TORTURE_OPTIONS]
105 global orig_environment_saved
107 # Deduce generated files from tool flags, return finalcode string
108 proc schedule-cleanups { opts } {
109 global additional_sources
112 lappend testcases [lindex [testname-for-summary] 0]
113 verbose "Cleanup testcases: $testcases" 4
114 if { [info exists additional_sources] && $additional_sources != "" } {
115 lappend testcases $additional_sources
116 verbose "Cleanup testcases, additional: $additional_sources" 4
118 verbose "Cleanup all options: $opts" 4
120 # First some fixups to transform stuff to something manageable ..
121 # --dump= should translate to -d with joined operand.
122 if [regexp -- {(^|\s+)--dump=[^\s]+(\s+|$)} $opts] {
123 regsub -all -- {--dump=} $opts {-d} opts
125 # -da and -dx are treated as shorthand for -fdump-rtl-all here
126 if [regexp -- {(^|\s+)-d[ax](\s+|$)} $opts] {
127 verbose "Cleanup -d seen" 4
128 lappend opts "-fdump-rtl-all"
130 # .. and don't question why there is
--dump
=? and
-d?
132 #
Then handle options that generate non
-dump files
134 #
-fprofile
-generate
-> cleanup
-coverage
-files
()
135 #
-fstack
-usage
-> cleanup
-stack
-usage
()
136 if [regexp
-- {(^|\s
+)-fstack
-usage
(\s
+|$
)} $opts
] {
137 verbose
"Cleanup -fstack-usage seen" 4
138 # append finalcode
"cleanup-stack-usage\n"
140 global keep_saved_temps_suffixes
141 if [info exists keep_saved_temps_suffixes
] {
142 verbose
"dg-keep-saved-temps ${keep_saved_temps_suffixes}" 2
144 #
-save
-temps
-> cleanup
-saved
-temps
()
145 if [regexp
-- {(^|\s
+)-save
-temps
(\s
+|$
)} $opts
] {
146 verbose
"Cleanup -save-temps seen" 4
147 if [info exists keep_saved_temps_suffixes
] {
148 append finalcode
"cleanup-saved-temps ${keep_saved_temps_suffixes}\n"
150 append finalcode
"cleanup-saved-temps\n"
153 if [info exists keep_saved_temps_suffixes
] {
154 error
"dg-keep-saved-temps specified but testcase does not -save-temps"
158 # Finally see
if there are
any dumps in opts
, otherwise we are done
159 if [regexp
-- {(?
=(?
:^|
[ \t]+)?
)-fdump
-[^
\t]+(?
=(?
:$|
[ \t]+)?
)} $opts
] {
160 # Ipa
, Rtl
, Tree
for simplicity
165 # stem.ext.
<passnum
><fam
>.
<passname
><pass
-instances
>
166 #
(tree
)passes can have multiple instances
, thus optional trailing
*
167 set ptn
"\[0-9\]\[0-9\]\[0-9\]$ptn.*"
168 # Handle ltrans files around
-flto
169 if [regexp
-- {(^|\s
+)-flto
(\s
+|$
)} $opts
] {
170 verbose
"Cleanup -flto seen" 4
171 set ltrans
"{ltrans\[0-9\]*.,}"
175 set ptn
"$ltrans$ptn"
176 verbose
"Cleanup final ptn: $ptn" 4
178 foreach src $testcases
{
179 set basename
[file tail $src
]
180 if { $ltrans
!= "" } {
181 # ??? should we use upvar
1 output_file instead of this
(dup ?
)
182 set stem
[file rootname $basename
]
183 set basename_ext
[file extension $basename
]
184 if {$basename_ext
!= ""} {
185 regsub
-- {^.
*\.
} $basename_ext
{} basename_ext
187 lappend tfiles
"$stem.{$basename_ext,exe}"
190 lappend tfiles $basename
193 if { [llength $tfiles
] > 1 } {
194 set tfiles
[join $tfiles
","]
195 set tfiles
"{$tfiles}"
197 verbose
"Cleanup final testcases: $tfiles" 4
198 # We have to quote the regex
199 regsub
-all
{([][$^?
+*()|
\\{}])} "$tfiles.$ptn" {\\\1} ptn
201 append final
{remove
-build
-file
}
202 append final
"\"$ptn\""
203 verbose
"Cleanup final: $final" 4
204 append finalcode
"$final\n"
209 #
Define gcc callbacks
for dg.exp.
211 proc gcc
-dg
-test
-1 { target_compile prog do_what extra_tool_flags
} {
212 #
Set up the compiler flags
, based
on what we
're going to do.
216 # Tests should be able to use "dg-do repo". However, the dg test
217 # driver checks the argument to dg-do against a list of acceptable
218 # options, and "repo" is not among them. Therefore, we resort to
219 # this ugly approach.
220 if [string match "*-frepo*" $extra_tool_flags] then {
226 set compile_type "preprocess"
227 set output_file "[file rootname [file tail $prog]].i"
230 set compile_type "assembly"
231 set output_file "[file rootname [file tail $prog]].s"
234 set compile_type "object"
235 set output_file "[file rootname [file tail $prog]].o"
238 set compile_type "precompiled_header"
239 set output_file "[file tail $prog].gch"
242 set compile_type "executable"
243 set output_file "[file rootname [file tail $prog]].exe"
244 # The following line is needed for targets like the i960 where
245 # the default output file is b.out. Sigh.
248 set compile_type "object"
249 set output_file "[file rootname [file tail $prog]].o"
252 set compile_type "executable"
253 # FIXME: "./" is to cope with "." not being in $PATH.
254 # Should this be handled elsewhere?
256 set output_file "./[file rootname [file tail $prog]].exe"
257 # This is the only place where we care if an executable was
258 # created or not. If it was, dg.exp will try to run it.
259 catch { remote_file build delete $output_file }
262 perror "$do_what: not a valid dg-do keyword"
267 # Let { dg-final { action } } force options as returned by an
268 # optional proc ${action}_required_options.
269 upvar 2 dg-final-code finalcode
270 foreach x [split $finalcode "\n"] {
271 set finalcmd [lindex $x 0]
272 if { [info procs ${finalcmd}_required_options] != "" } {
273 set req [${finalcmd}_required_options]
274 if { $req != "" && [lsearch -exact $extra_tool_flags $req] == -1 } {
275 lappend extra_tool_flags $req
280 append finalcode [schedule-cleanups "$options $extra_tool_flags"]
281 if { $extra_tool_flags != "" } {
282 lappend options "additional_flags=$extra_tool_flags"
285 verbose "$target_compile $prog $output_file $compile_type $options" 4
286 set comp_output [$target_compile "$prog" "$output_file" "$compile_type" $options]
288 # Look for an internal compiler error, which sometimes masks the fact
289 # that we didn't
get an expected error message. XFAIL an ICE via
290 # dg
-xfail
-if and use
{ dg
-prune
-output
".*internal compiler error.*" }
291 # to avoid a second failure
for excess errors.
292 if [string match
"*internal compiler error*" $comp_output] {
294 fail
"$name (internal compiler error)"
297 if { $do_what
== "repo" } {
298 set object_file
"$output_file"
299 set output_file
"[file rootname [file tail $prog]].exe"
301 [ concat $comp_output \
302 [$target_compile
"$object_file" "$output_file" \
303 "executable" $options] ]
306 return [list $comp_output $output_file
]
309 proc gcc
-dg
-test
{ prog do_what extra_tool_flags
} {
310 return [gcc
-dg
-test
-1 gcc_target_compile $prog $do_what $extra_tool_flags
]
313 # Global
: should
blank lines be allowed in the output?
314 # By default
, they should not be.
(PR other
/69006)
315 # However
, there are some ways
for them to validly occur.
316 set allow_blank_lines
0
318 # A command
for use by testcases to mark themselves as expecting
319 #
blank lines in the output.
321 proc dg
-allow
-blank-lines
-in
-output
{ args } {
322 global allow_blank_lines
323 set allow_blank_lines
1
326 proc gcc
-dg
-prune
{ system text } {
327 global additional_prunes
329 # Extra prune rules that will apply to tests defined in a .exp file.
330 # Always remember to clear it in .exp file after executed all tests.
331 global dg_runtest_extra_prunes
333 # Complain about
blank lines in the output
(PR other
/69006)
334 global allow_blank_lines
335 if { !$allow_blank_lines
} {
336 set num_blank_lines
[llength
[regexp
-all
-inline
"\n\n" $text]]
337 if { $num_blank_lines
} {
338 global testname_with_flags
339 fail
"$testname_with_flags $num_blank_lines blank line(s) in output"
341 set allow_blank_lines
0
344 set text [prune_gcc_output $
text]
346 foreach p
"$additional_prunes $dg_runtest_extra_prunes" {
347 if { [string length $p
] > 0 } {
348 # Following regexp matches a complete line containing $p.
349 regsub
-all
"(^|\n)\[^\n\]*$p\[^\n\]*" $text "" text
353 #
If we see
"region xxx is full" then the testcase is too big for ram.
354 # This is tricky to deal with in a large testsuite like c
-torture so
355 # deal with it here. Just mark the testcase as unsupported.
356 if [regexp
"(^|\n)\[^\n\]*: region \[^\n\]* is full" $text] {
357 # The format here is important. See dg.exp.
358 return "::unsupported::memory full"
361 if { [regexp
"(^|\n)\[^\n\]*: relocation truncated to fit" $text]
362 && [check_effective_target_tiny
] } {
363 return "::unsupported::memory full"
366 # Likewise
, if we see
".text exceeds local store range" or
368 if {[string match
"spu-*" $system] && \
369 [string match
"*exceeds local store*" $text]} {
370 # The format here is important. See dg.exp.
371 return "::unsupported::memory full"
377 # Replace $
{tool
}_load with a wrapper to provide
for an expected nonzero
378 # exit
status. Multiple languages
include this file so this handles them
380 if { [info procs $
{tool
}_load
] != [list
] \
381 && [info procs saved_$
{tool
}_load
] == [list
] } {
382 rename $
{tool
}_load saved_$
{tool
}_load
384 proc $
{tool
}_load
{ program args } {
387 global set_target_env_var
389 set saved_target_env_var
[list
]
390 if { [info exists set_target_env_var
] \
391 && [llength $set_target_env_var
] != 0 } {
392 if { [is_remote target
] } {
393 return [list
"unsupported" ""]
397 set result
[eval
[list saved_$
{tool
}_load $
program] $
args]
398 if { [info exists set_target_env_var
] \
399 && [llength $set_target_env_var
] != 0 } {
400 restore
-target
-env
-var
402 if { $shouldfail
!= 0 } {
403 switch [lindex $result
0] {
404 "pass" { set status "fail" }
405 "fail" { set status "pass" }
406 default
{ set status [lindex $result
0] }
408 set result
[list $
status [lindex $result
1]]
411 set result
[list
[lindex $result
0] [prune_file_path
[lindex $result
1]]]
416 proc dg
-set-target
-env
-var
{ args } {
417 global set_target_env_var
418 if { [llength $
args] != 3 } {
419 error
"dg-set-target-env-var: need two arguments"
422 lappend set_target_env_var
[list
[lindex $
args 1] [lindex $
args 2]]
425 proc
set-target
-env
-var
{ } {
426 global set_target_env_var
427 upvar
1 saved_target_env_var saved_target_env_var
428 foreach env_var $set_target_env_var
{
429 set var
[lindex $env_var
0]
430 set value
[lindex $env_var
1]
431 if [info exists ::env
($var
)] {
432 lappend saved_target_env_var
[list $var
1 $
::env
($var
)]
434 lappend saved_target_env_var
[list $var
0]
440 proc restore
-target
-env
-var
{ } {
441 upvar
1 saved_target_env_var saved_target_env_var
442 for { set env_vari
[llength $saved_target_env_var
] } {
443 [incr env_vari
-1] >= 0 } {} {
444 set env_var
[lindex $saved_target_env_var $env_vari
]
445 set var
[lindex $env_var
0]
446 if [lindex $env_var
1] {
447 setenv $var
[lindex $env_var
2]
454 proc dg
-set-compiler
-env
-var
{ args } {
455 global set_compiler_env_var
456 global saved_compiler_env_var
457 if { [llength $
args] != 3 } {
458 error
"dg-set-compiler-env-var: need two arguments"
461 set var
[lindex $
args 1]
462 set value
[lindex $
args 2]
463 if [info exists ::env
($var
)] {
464 lappend saved_compiler_env_var
[list $var
1 $
::env
($var
)]
466 lappend saved_compiler_env_var
[list $var
0]
469 lappend set_compiler_env_var
[list $var $value
]
472 proc restore
-compiler
-env
-var
{ } {
473 global saved_compiler_env_var
474 for { set env_vari
[llength $saved_compiler_env_var
] } {
475 [incr env_vari
-1] >= 0 } {} {
476 set env_var
[lindex $saved_compiler_env_var $env_vari
]
477 set var
[lindex $env_var
0]
478 if [lindex $env_var
1] {
479 setenv $var
[lindex $env_var
2]
489 # search_for
-- looks
for a string match in a file
491 proc search_for
{ file pattern
} {
492 set fd
[open $file r
]
493 while { [gets $fd cur_line
]>=0 } {
494 if [string match
"*$pattern*" $cur_line] then {
503 # Modified dg
-runtest that can cycle through a list of optimization options
505 proc gcc
-dg
-runtest
{ testcases flags default
-extra
-flags
} {
508 # Some callers
set torture options themselves
; don
't override those.
509 set existing_torture_options [torture-options-exist]
510 if { $existing_torture_options == 0 } {
511 global DG_TORTURE_OPTIONS LTO_TORTURE_OPTIONS
513 set-torture-options $DG_TORTURE_OPTIONS [list {}] $LTO_TORTURE_OPTIONS
517 foreach test $testcases {
518 global torture_with_loops torture_without_loops
519 # If we're only testing specific files and this isn
't one of
521 if ![runtest_file_p $runtests $test] {
525 # Look for a loop within the source code - if we don't find one
,
526 # don
't pass -funroll[-all]-loops.
527 if [expr [search_for $test "for*("]+[search_for $test "while*("]] {
528 set option_list $torture_with_loops
530 set option_list $torture_without_loops
533 set nshort [file tail [file dirname $test]]/[file tail $test]
535 foreach flags_t $option_list {
536 verbose "Testing $nshort, $flags $flags_t" 1
537 dg-test $test "$flags $flags_t" ${default-extra-flags}
541 if { $existing_torture_options == 0 } {
546 proc gcc-dg-debug-runtest { target_compile trivial opt_opts testcases } {
549 if ![info exists DEBUG_TORTURE_OPTIONS] {
550 set DEBUG_TORTURE_OPTIONS ""
551 foreach type {-gdwarf-2 -gstabs -gstabs+ -gxcoff -gxcoff+ -gcoff} {
552 set comp_output [$target_compile \
553 "$srcdir/$subdir/$trivial" "trivial.S" assembly \
554 "additional_flags=$type"]
555 if { ! [string match "*: target system does not support the * debug format*" \
557 remove-build-file "trivial.S"
558 foreach level {1 "" 3} {
559 if { ($type == "-gdwarf-2") && ($level != "") } {
560 lappend DEBUG_TORTURE_OPTIONS [list "${type}" "-g${level}"]
561 foreach opt $opt_opts {
562 lappend DEBUG_TORTURE_OPTIONS \
563 [list "${type}" "-g${level}" "$opt" ]
566 lappend DEBUG_TORTURE_OPTIONS [list "${type}${level}"]
567 foreach opt $opt_opts {
568 lappend DEBUG_TORTURE_OPTIONS \
569 [list "${type}${level}" "$opt" ]
577 verbose -log "Using options $DEBUG_TORTURE_OPTIONS"
581 foreach test $testcases {
582 # If we're only testing specific files and this isn
't one of
584 if ![runtest_file_p $runtests $test] {
588 set nshort [file tail [file dirname $test]]/[file tail $test]
590 foreach flags $DEBUG_TORTURE_OPTIONS {
593 # These tests check for information which may be deliberately
595 if { ([string match {*/debug-[126].c} "$nshort"] \
596 || [string match {*/enum-1.c} "$nshort"] \
597 || [string match {*/enum-[12].C} "$nshort"]) \
598 && ([string match "*1" [lindex "$flags" 0] ]
599 || [lindex "$flags" 1] == "-g1") } {
603 # High optimization can remove the variable whose existence is tested.
604 # Dwarf debugging with commentary (-dA) preserves the symbol name in the
605 # assembler output, but stabs debugging does not.
606 # http://gcc.gnu.org/ml/gcc-regression/2003-04/msg00095.html
607 if { [string match {*/debug-[12].c} "$nshort"] \
608 && [string match "*O*" "$flags"] \
609 && ( [string match "*coff*" "$flags"] \
610 || [string match "*stabs*" "$flags"] ) } {
615 verbose -log "Testing $nshort, $flags" 1
616 dg-test $test $flags ""
622 # Prune any messages matching ARGS[1] (a regexp) from test output.
623 proc dg-prune-output { args } {
624 global additional_prunes
626 if { [llength $args] != 2 } {
627 error "[lindex $args 1]: need one argument"
631 lappend additional_prunes [lindex $args 1]
634 # Remove files matching the pattern from the build machine.
635 proc remove-build-file { pat } {
636 verbose "remove-build-file `$pat'" 2
637 set file_list
"[glob -nocomplain $pat]"
638 verbose
"remove-build-file `$file_list'" 2
639 foreach output_file $file_list
{
640 if [is_remote host
] {
641 # Ensure the host knows the file is gone by deleting there
643 remote_file host
delete $output_file
645 remote_file build
delete $output_file
649 # Remove runtime
-generated profile file
for the current test.
650 proc cleanup
-profile
-file
{ } {
651 remove
-build
-file
"mon.out"
652 remove
-build
-file
"gmon.out"
655 # Remove compiler
-generated coverage files
for the current test.
656 proc cleanup
-coverage
-files
{ } {
657 global additional_sources_used
658 set testcase
[testname
-for-summary
]
659 # The
name might
include a list of options
; extract the file
name.
660 set testcase
[lindex $testcase
0]
661 remove
-build
-file
"[file rootname [file tail $testcase]].gc??"
663 # Clean up coverage files
for additional source files.
664 if [info exists additional_sources_used
] {
665 foreach srcfile $additional_sources_used
{
666 remove
-build
-file
"[file rootname [file tail $srcfile]].gc??"
671 # Remove compiler
-generated files from
-repo
for the current test.
672 proc cleanup
-repo
-files
{ } {
673 global additional_sources_used
674 set testcase
[testname
-for-summary
]
675 # The
name might
include a list of options
; extract the file
name.
676 set testcase
[lindex $testcase
0]
677 remove
-build
-file
"[file rootname [file tail $testcase]].o"
678 remove
-build
-file
"[file rootname [file tail $testcase]].rpo"
680 # Clean up files
for additional source files.
681 if [info exists additional_sources_used
] {
682 foreach srcfile $additional_sources_used
{
683 remove
-build
-file
"[file rootname [file tail $srcfile]].o"
684 remove
-build
-file
"[file rootname [file tail $srcfile]].rpo"
689 # Remove a final insns dump file
for the current test.
690 proc cleanup
-final
-insns
-dump
{ } {
691 set testcase
[testname
-for-summary
]
692 # The
name might
include a list of options
; extract the file
name.
693 set testcase
[lindex $testcase
0]
694 remove
-build
-file
"[file rootname [file tail $testcase]].s.gkd"
696 # Clean up files
for additional source files.
697 if [info exists additional_sources_used
] {
698 foreach srcfile $additional_sources_used
{
699 remove
-build
-file
"[file rootname [file tail $srcfile]].s.gkd"
704 # Remove a stack usage file
for the current test.
705 proc cleanup
-stack
-usage
{ } {
706 set testcase
[testname
-for-summary
]
707 # The
name might
include a list of options
; extract the file
name.
708 set testcase
[lindex $testcase
0]
709 remove
-build
-file
"[file rootname [file tail $testcase]].su"
711 # Clean up files
for additional source files.
712 if [info exists additional_sources_used
] {
713 foreach srcfile $additional_sources_used
{
714 remove
-build
-file
"[file rootname [file tail $srcfile]].su"
719 # Remove an Ada spec file
for the current test.
720 proc cleanup
-ada
-spec
{ } {
721 global additional_sources_used
722 set testcase
[testname
-for-summary
]
723 remove
-build
-file
"[get_ada_spec_filename $testcase]"
725 # Clean up files
for additional source files.
726 if [info exists additional_sources_used
] {
727 foreach srcfile $additional_sources_used
{
728 remove
-build
-file
"[get_ada_spec_filename $srcfile]"
733 # Remove files kept by
--save
-temps
for the current test.
735 # Currently this is only .i
, .ii
, .s and .o files
, but more can be added
736 #
if there are tests generating them.
737 #
ARGS is a list of suffixes to NOT
delete.
738 proc cleanup
-saved
-temps
{ args } {
739 global additional_sources_used
742 # add the to
-be
-kept suffixes
743 foreach suffix
{".mii" ".ii" ".i" ".s" ".o" ".gkd" ".res" ".ltrans.out"} {
744 if {[lsearch $
args $suffix
] < 0} {
745 lappend suffixes $suffix
749 set testcase
[testname
-for-summary
]
750 # The
name might
include a list of options
; extract the file
name.
751 set testcase
[lindex $testcase
0]
752 foreach suffix $suffixes
{
753 remove
-build
-file
"[file rootname [file tail $testcase]]$suffix"
754 remove
-build
-file
"[file rootname [file tail $testcase]].exe$suffix"
755 remove
-build
-file
"[file rootname [file tail $testcase]].exe.ltrans\[0-9\]*$suffix"
756 #
-fcompare
-debug dumps
757 remove
-build
-file
"[file rootname [file tail $testcase]].gk$suffix"
760 # Clean up saved temp files
for additional source files.
761 if [info exists additional_sources_used
] {
762 foreach srcfile $additional_sources_used
{
763 foreach suffix $suffixes
{
764 remove
-build
-file
"[file rootname [file tail $srcfile]]$suffix"
765 remove
-build
-file
"[file rootname [file tail $srcfile]].exe$suffix"
766 remove
-build
-file
"[file rootname [file tail $srcfile]].exe.ltrans\[0-9\]*$suffix"
768 #
-fcompare
-debug dumps
769 remove
-build
-file
"[file rootname [file tail $srcfile]].gk$suffix"
776 # Files to be kept after cleanup of
--save
-temps
for the current test.
777 #
ARGS is a list of suffixes to NOT
delete.
778 proc dg
-keep
-saved
-temps
{ args } {
779 global keep_saved_temps_suffixes
780 set keep_saved_temps_suffixes
{}
782 # add the to
-be
-kept suffixes
783 foreach suffix
{".mii" ".ii" ".i" ".s" ".o" ".gkd" ".res" ".ltrans.out"} {
784 if {[lsearch $
args $suffix
] >= 0} {
785 lappend keep_saved_temps_suffixes $suffix
788 if { [llength keep_saved_temps_suffixes
] < 1 } {
789 error
"dg-keep-saved-temps ${args} did not match any known suffix"
793 # Scan Fortran modules
for a given regexp.
795 #
Argument 0 is the module
name
796 #
Argument 1 is the regexp to match
797 proc scan
-module
{ args } {
798 set modfilename
[string tolower
[lindex $
args 0]].mod
799 set fd
[open
[list | gzip
-dc $modfilename
] r
]
803 set testcase
[testname
-for-summary
]
804 if [regexp
-- [lindex $
args 1] $
text] {
805 pass
"$testcase scan-module [lindex $args 1]"
807 fail
"$testcase scan-module [lindex $args 1]"
811 # Scan Fortran modules
for absence of a given regexp.
813 #
Argument 0 is the module
name
814 #
Argument 1 is the regexp to match
815 proc scan
-module
-absence
{ args } {
816 set modfilename
[string tolower
[lindex $
args 0]].mod
817 set fd
[open
[list | gzip
-dc $modfilename
] r
]
821 set testcase
[testname
-for-summary
]
822 if [regexp
-- [lindex $
args 1] $
text] {
823 fail
"$testcase scan-module [lindex $args 1]"
825 pass
"$testcase scan-module [lindex $args 1]"
829 # Verify that the compiler output file
exists, invoked via dg
-final.
830 proc output
-exists { args } {
831 # Process an optional target or xfail list.
832 if { [llength $
args] >= 1 } {
833 switch [dg
-process
-target
[lindex $
args 0]] {
836 "F" { setup_xfail "*-*-*" }
841 set testcase
[testname
-for-summary
]
842 # Access
variable from gcc
-dg
-test
-1.
843 upvar
2 output_file output_file
845 if [file
exists $output_file
] {
846 pass
"$testcase output-exists $output_file"
848 fail
"$testcase output-exists $output_file"
852 # Verify that the compiler output file does not exist
, invoked via dg
-final.
853 proc output
-exists-not
{ args } {
854 # Process an optional target or xfail list.
855 if { [llength $
args] >= 1 } {
856 switch [dg
-process
-target
[lindex $
args 0]] {
859 "F" { setup_xfail "*-*-*" }
864 set testcase
[testname
-for-summary
]
865 # Access
variable from gcc
-dg
-test
-1.
866 upvar
2 output_file output_file
868 if [file
exists $output_file
] {
869 fail
"$testcase output-exists-not $output_file"
871 pass
"$testcase output-exists-not $output_file"
875 # We need to make sure that additional_
* are cleared out after
every
876 # test. It is not enough to clear them out
*before
* the next test run
877 # because gcc
-target
-compile gets run directly from some .exp files
878 #
(outside of
any test
).
(Those uses should eventually be eliminated.
)
880 # Because the DG framework doesn
't provide a hook that is run at the
881 # end of a test, we must replace dg-test with a wrapper.
883 if { [info procs saved-dg-test] == [list] } {
884 rename dg-test saved-dg-test
886 # Helper function for cleanups that should happen after the call
887 # to the real dg-test, whether or not it returns normally, or
888 # fails with an error.
889 proc cleanup-after-saved-dg-test { } {
890 global additional_files
891 global additional_sources
892 global additional_sources_used
893 global additional_prunes
894 global compiler_conditional_xfail_data
896 global testname_with_flags
897 global set_target_env_var
898 global set_compiler_env_var
899 global saved_compiler_env_var
900 global keep_saved_temps_suffixes
901 global multiline_expected_outputs
902 global freeform_regexps
904 set additional_files ""
905 set additional_sources ""
906 set additional_sources_used ""
907 set additional_prunes ""
909 if [info exists set_target_env_var] {
910 unset set_target_env_var
912 if [info exists set_compiler_env_var] {
913 restore-compiler-env-var
914 unset set_compiler_env_var
915 unset saved_compiler_env_var
917 if [info exists keep_saved_temps_suffixes] {
918 unset keep_saved_temps_suffixes
921 if [info exists compiler_conditional_xfail_data] {
922 unset compiler_conditional_xfail_data
924 if [info exists testname_with_flags] {
925 unset testname_with_flags
927 set multiline_expected_outputs []
928 set freeform_regexps []
931 proc dg-test { args } {
934 if { [ catch { eval saved-dg-test $args } errmsg ] } {
935 set saved_info $errorInfo
936 cleanup-after-saved-dg-test
937 error $errmsg $saved_info
939 cleanup-after-saved-dg-test
943 if { [info procs saved-dg-warning] == [list] \
944 && [info exists gcc_warning_prefix] } {
945 rename dg-warning saved-dg-warning
947 proc dg-warning { args } {
948 # Make this variable available here and to the saved proc.
949 upvar dg-messages dg-messages
950 global gcc_warning_prefix
952 process-message saved-dg-warning "$gcc_warning_prefix" "$args"
956 if { [info procs saved-dg-error] == [list] \
957 && [info exists gcc_error_prefix] } {
958 rename dg-error saved-dg-error
960 proc dg-error { args } {
961 # Make this variable available here and to the saved proc.
962 upvar dg-messages dg-messages
963 global gcc_error_prefix
965 process-message saved-dg-error "$gcc_error_prefix" "$args"
968 # Override dg-bogus at the same time. It doesn't handle a prefix
969 # but its expression should
include a column number. Otherwise the
970 # line number can match the column number
for other messages
, leading
972 rename dg
-bogus saved
-dg
-bogus
974 proc dg
-bogus
{ args } {
975 upvar dg
-messages dg
-messages
976 process
-message saved
-dg
-bogus
"" $args
980 # Modify the regular expression saved by a DejaGnu message directive to
981 #
include a prefix and to force the expression to match a single line.
982 # MSGPROC is the procedure to
call.
983 # MSGPREFIX is the prefix to prepend.
984 # DGARGS is the original
argument list.
986 proc process
-message
{ msgproc msgprefix dgargs
} {
987 upvar dg
-messages dg
-messages
989 # Handle relative line specification
, .
+1 or .
-1 etc.
990 if { [llength $dgargs
] == 5
991 && [regsub
"^\.\[+-\](\[0-9\])$" [lindex $dgargs 4] "\\1" num] } {
992 set num
[expr
[lindex $dgargs
0] [string index
[lindex $dgargs
4] 1] $num
]
993 set dgargs
[lreplace $dgargs
4 4 $num
]
996 # Process the dg
- directive
, including adding the regular expression
997 # to the new message entry in dg
-messages.
998 set msgcnt
[llength $
{dg
-messages
}]
999 eval $msgproc $dgargs
1001 #
If the target expression wasn
't satisfied there is no new message.
1002 if { [llength ${dg-messages}] == $msgcnt } {
1006 # Get the entry for the new message. Prepend the message prefix to
1007 # the regular expression and make it match a single line.
1008 set newentry [lindex ${dg-messages} end]
1009 set expmsg [lindex $newentry 2]
1011 # Handle column numbers from the specified expression (if there is
1012 # one) and set up the search expression that will be used by DejaGnu.
1013 if [regexp "^(\[0-9\]+):" $expmsg "" column] {
1014 # The expression in the directive included a column number.
1015 # Remove "COLUMN:" from the original expression and move it
1016 # to the proper place in the search expression.
1017 regsub "^\[0-9\]+:" $expmsg "" expmsg
1018 set expmsg "$column: $msgprefix\[^\n\]*$expmsg"
1019 } elseif [string match "" [lindex $newentry 0]] {
1020 # The specified line number is 0; don't expect a column number.
1021 set expmsg
"$msgprefix\[^\n\]*$expmsg"
1023 # There is no column number in the search expression
, but we
1024 # should expect one in the message itself.
1025 set expmsg
"\[0-9\]+: $msgprefix\[^\n\]*$expmsg"
1028 set newentry
[lreplace $newentry
2 2 $expmsg
]
1029 set dg
-messages
[lreplace $
{dg
-messages
} end end $newentry
]
1030 verbose
"process-message:\n${dg-messages}" 2
1033 # Look
for messages that don
't have standard prefixes.
1035 proc dg-message { args } {
1036 upvar dg-messages dg-messages
1037 process-message saved-dg-warning "" $args
1040 # Look for a location marker of the form
1042 # with no extra text (e.g. a line-span separator).
1044 proc dg-locus { args } {
1045 upvar dg-messages dg-messages
1047 # Process the dg- directive, including adding the regular expression
1048 # to the new message entry in dg-messages.
1049 set msgcnt [llength ${dg-messages}]
1050 eval saved-dg-warning $args
1052 # If the target expression wasn't satisfied there is no new message.
1053 if { [llength $
{dg
-messages
}] == $msgcnt
} {
1057 #
Get the entry
for the new message. Prepend the message prefix to
1058 # the regular expression and make it match a single line.
1059 set newentry
[lindex $
{dg
-messages
} end
]
1060 set expmsg
[lindex $newentry
2]
1062 set newentry
[lreplace $newentry
2 2 $expmsg
]
1063 set dg
-messages
[lreplace $
{dg
-messages
} end end $newentry
]
1064 verbose
"process-message:\n${dg-messages}" 2
1067 # Check the existence of a gdb in the path
, and
return true
if there
1070 #
Set env
(GDB_FOR_GCC_TESTING
) accordingly.
1072 proc gdb
-exists { args } {
1073 if ![info exists ::env
(GDB_FOR_GCC_TESTING
)] {
1075 if ![info exists ::env
(GDB_FOR_GCC_TESTING
)] {
1076 if [info exists GDB
] {
1077 setenv GDB_FOR_GCC_TESTING
"$GDB"
1079 setenv GDB_FOR_GCC_TESTING
"[transform gdb]"
1083 if { [which $
::env
(GDB_FOR_GCC_TESTING
)] != 0 } {
1089 set additional_prunes
""
1090 set dg_runtest_extra_prunes
""