1 # Copyright (C) 1997, 1999, 2000 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 2 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 this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 load_lib file-format.exp
19 load_lib target-supports.exp
22 if ![info exists TORTURE_OPTIONS] {
23 # It is theoretically beneficial to group all of the O2/O3 options together,
24 # as in many cases the compiler will generate identical executables for
25 # all of them--and the c-torture testsuite will skip testing identical
26 # executables multiple times.
27 # Also note that -finline-functions is explicitly included in one of the
28 # items below, even though -O3 is also specified, because some ports may
29 # choose to disable inlining functions by default, even when optimizing.
30 set TORTURE_OPTIONS [list \
34 { -O3 -fomit-frame-pointer } \
35 { -O3 -fomit-frame-pointer -funroll-loops } \
36 { -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions } \
42 # Split TORTURE_OPTIONS into two choices: one for testcases with loops and
43 # one for testcases without loops.
45 set torture_with_loops $TORTURE_OPTIONS
46 set torture_without_loops ""
47 foreach option $TORTURE_OPTIONS {
48 if ![string match "*loop*" $option] {
49 lappend torture_without_loops $option
53 # Define gcc callbacks for dg.exp.
55 proc gcc-dg-test { prog do_what extra_tool_flags } {
56 # Set up the compiler flags, based on what we're going to do.
60 set compile_type "preprocess"
61 set output_file "[file rootname [file tail $prog]].i"
64 set compile_type "assembly"
65 set output_file "[file rootname [file tail $prog]].s"
68 set compile_type "object"
69 set output_file "[file rootname [file tail $prog]].o"
72 set compile_type "executable"
73 set output_file "a.out"
74 # The following line is needed for targets like the i960 where
75 # the default output file is b.out. Sigh.
78 set compile_type "executable"
79 # FIXME: "./" is to cope with "." not being in $PATH.
80 # Should this be handled elsewhere?
82 set output_file "./a.out"
83 # This is the only place where we care if an executable was
84 # created or not. If it was, dg.exp will try to run it.
85 remote_file build delete $output_file;
88 perror "$do_what: not a valid dg-do keyword"
93 if { $extra_tool_flags != "" } {
94 lappend options "additional_flags=$extra_tool_flags"
97 set comp_output [gcc_target_compile "$prog" "$output_file" "$compile_type" $options];
99 return [list $comp_output $output_file]
102 proc gcc-dg-prune { system text } {
103 set text [prune_gcc_output $text]
105 # If we see "region xxx is full" then the testcase is too big for ram.
106 # This is tricky to deal with in a large testsuite like c-torture so
107 # deal with it here. Just mark the testcase as unsupported.
108 if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $text] {
109 # The format here is important. See dg.exp.
110 return "::unsupported::memory full"
119 # search_for -- looks for a string match in a file
121 proc search_for { file pattern } {
122 set fd [open $file r]
123 while { [gets $fd cur_line]>=0 } {
124 if [string match "*$pattern*" $cur_line] then {
133 # Modified dg-runtest that can cycle through a list of optimization options
135 proc gcc-dg-runtest { testcases default-extra-flags } {
138 foreach test $testcases {
139 # If we're only testing specific files and this isn't one of
141 if ![runtest_file_p $runtests $test] {
145 # Look for a loop within the source code - if we don't find one,
146 # don't pass -funroll[-all]-loops.
147 global torture_with_loops torture_without_loops
148 if [expr [search_for $test "for*("]+[search_for $test "while*("]] {
149 set option_list $torture_with_loops
151 set option_list $torture_without_loops
154 set nshort [file tail [file dirname $test]]/[file tail $test]
156 foreach flags $option_list {
157 verbose "Testing $nshort, $flags" 1
158 dg-test $test $flags ${default-extra-flags}