Merged with mainline at revision 128810.
[official-gcc.git] / gcc / testsuite / lib / mike-gcc.exp
blob9e85fefcffea483d410d4edee9059cf33f0c8f29
1 # Copyright (C) 1988, 90, 91, 92, 95, 96, 1997, 2007
2 # Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with GCC; see the file COPYING3. If not see
16 # <http://www.gnu.org/licenses/>.
18 # This file was derived from mike-g++.exp written by Mike Stump <mrs@cygnus.com>
21 # mike_cleanup -- remove any files that are created by the testcase
23 proc mike_cleanup { src_code output_file assembly_file } {
24 remote_file build delete $output_file $assembly_file
28 # prebase -- sets up a Mike Stump (mrs@cygnus.com) style gcc test
30 proc prebase { } {
31 global compiler_output
32 global not_compiler_output
33 global compiler_result
34 global not_compiler_result
35 global program_output
36 global groups
37 global run
38 global actions
39 global target_regexp
41 set compiler_output "^$"
42 set not_compiler_output ".*Internal compiler error.*"
43 set compiler_result ""
44 set not_compiler_result ""
45 set program_output ".*PASS.*"
46 set groups {}
47 set run no
48 set actions assemble
49 set target_regexp ".*"
53 # run the test
55 proc postbase { src_code run groups args } {
56 global verbose
57 global srcdir
58 global subdir
59 global not_compiler_output
60 global compiler_output
61 global compiler_result
62 global not_compiler_result
63 global program_output
64 global actions
65 global target_regexp
66 global host_triplet
67 global target_triplet
68 global tool
69 global tmpdir
70 global GCC_UNDER_TEST
71 global GROUP
73 if ![info exists GCC_UNDER_TEST] {
74 error "No compiler specified for testing."
77 if ![regexp $target_regexp $target_triplet] {
78 unsupported $subdir/$src_code
79 return
82 if { [llength $args] > 0 } {
83 set comp_options [lindex $args 0]
84 } else {
85 set comp_options ""
88 set fail_message $subdir/$src_code
89 set pass_message $subdir/$src_code
91 if [info exists GROUP] {
92 if {[lsearch $groups $GROUP] == -1} {
93 return
97 if [string match $run yes] {
98 set actions run
101 set output_file "$tmpdir/[file tail [file rootname $src_code]]"
102 set assembly_file "$output_file"
103 append assembly_file ".S"
105 set compile_type "none"
107 case $actions {
108 compile
110 set compile_type "assembly"
111 set output_file $assembly_file
113 assemble
115 set compile_type "object"
116 append output_file ".o"
118 link
120 set compile_type "executable"
121 append output_file ".exe"
125 set compile_type "executable"
126 append output_file ".exe"
127 set run yes
129 default
131 set output_file ""
132 set compile_type "none"
136 set src_file "$srcdir/$subdir/$src_code"
137 set options ""
138 lappend options "compiler=$GCC_UNDER_TEST"
140 if { $comp_options != "" } {
141 lappend options "additional_flags=$comp_options"
144 set comp_output [gcc_target_compile $src_file $output_file $compile_type $options]
146 set pass no
148 # Delete things like "ld.so warning" messages.
149 set comp_output [prune_warnings $comp_output]
151 if [regexp -- $not_compiler_output $comp_output] {
152 if { $verbose > 1 } {
153 send_user "\nChecking:\n$not_compiler_output\nto make sure it does not match:\n$comp_output\nbut it does.\n\n"
154 } else {
155 send_log "\nCompiler output:\n$comp_output\n\n"
157 fail $fail_message
158 # The framework doesn't like to see any error remnants,
159 # so remove them.
160 uplevel {
161 if [info exists errorInfo] {
162 unset errorInfo
165 mike_cleanup $src_code $output_file $assembly_file
166 return
169 # remove any leftover CRs.
170 regsub -all -- "\r" $comp_output "" comp_output
172 regsub -all "(^|\n)\[^\n\]*linker input file unused since linking not done" $comp_output "" comp_output
173 regsub -all "(^|\n)\[^\n\]*file path prefix \[^\n\]* never used" $comp_output "" comp_output
175 set unsupported_message [${tool}_check_unsupported_p $comp_output]
176 if { $unsupported_message != "" } {
177 unsupported "$subdir/$src_code: $unsupported_message"
178 mike_cleanup $src_code $output_file $assembly_file
179 return
182 if { $verbose > 1 } {
183 send_user "\nChecking:\n$compiler_output\nto see if it matches:\n$comp_output\n"
184 } else {
185 send_log "\nCompiler output:\n$comp_output\n\n"
187 if [regexp -- $compiler_output $comp_output] {
188 if { $verbose > 1 } {
189 send_user "Yes, it matches.\n\n"
191 set pass yes
192 if [file exists [file rootname [file tail $src_code]].s] {
193 set fd [open [file rootname [file tail $src_code]].s r]
194 set dot_s [read $fd]
195 close $fd
196 if { $compiler_result != "" } {
197 verbose "Checking .s file for $compiler_result" 2
198 if [regexp -- $compiler_result $dot_s] {
199 verbose "Yes, it matches." 2
200 } else {
201 verbose "Nope, doesn't match." 2
202 verbose $dot_s 4
203 set pass no
206 if { $not_compiler_result != "" } {
207 verbose "Checking .s file for not $not_compiler_result" 2
208 if ![regexp -- $not_compiler_result $dot_s] {
209 verbose "Nope, not found (that's good)." 2
210 } else {
211 verbose "Uh oh, it was found." 2
212 verbose $dot_s 4
213 set pass no
217 if [string match $run yes] {
218 set result [gcc_load $output_file]
219 set status [lindex $result 0]
220 set output [lindex $result 1]
221 if { $status == -1 } {
222 mike_cleanup $src_code $output_file $assembly_file
223 return
225 if { $verbose > 1 } {
226 send_user "Checking:\n$program_output\nto see if it matches:\n$output\n\n"
228 if ![regexp -- $program_output $output] {
229 set pass no
230 if { $verbose > 1 } {
231 send_user "Nope, does not match.\n\n"
233 } else {
234 if { $verbose > 1 } {
235 send_user "Yes, it matches.\n\n"
239 } else {
240 if { $verbose > 1 } {
241 send_user "Nope, does not match.\n\n"
245 if [string match $pass "yes"] {
246 pass $pass_message
247 } else {
248 fail $fail_message
251 # The framework doesn't like to see any error remnants,
252 # so remove them.
253 uplevel {
254 if [info exists errorInfo] {
255 unset errorInfo
259 mike_cleanup $src_code $output_file $assembly_file