2014-07-29 Ed Smith-Rowland <3dw4rd@verizon.net>
[official-gcc.git] / gcc / testsuite / lib / mike-gcc.exp
blob68cca239b031ccdefaf70d423bd33732184ec62d
1 # Copyright (C) 1988-2014 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.
7 #
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/>.
17 # This file was derived from mike-g++.exp written by Mike Stump <mrs@cygnus.com>
20 # mike_cleanup -- remove any files that are created by the testcase
22 proc mike_cleanup { src_code output_file assembly_file } {
23 remote_file build delete $output_file $assembly_file
27 # prebase -- sets up a Mike Stump (mrs@cygnus.com) style gcc test
29 proc prebase { } {
30 global compiler_output
31 global not_compiler_output
32 global compiler_result
33 global not_compiler_result
34 global program_output
35 global groups
36 global run
37 global actions
38 global target_regexp
40 set compiler_output "^$"
41 set not_compiler_output ".*Internal compiler error.*"
42 set compiler_result ""
43 set not_compiler_result ""
44 set program_output ".*PASS.*"
45 set groups {}
46 set run no
47 set actions assemble
48 set target_regexp ".*"
52 # run the test
54 proc postbase { src_code run groups args } {
55 global verbose
56 global srcdir
57 global subdir
58 global not_compiler_output
59 global compiler_output
60 global compiler_result
61 global not_compiler_result
62 global program_output
63 global actions
64 global target_regexp
65 global host_triplet
66 global target_triplet
67 global tool
68 global tmpdir
69 global GCC_UNDER_TEST
70 global GROUP
72 if ![info exists GCC_UNDER_TEST] {
73 error "No compiler specified for testing."
76 if ![regexp $target_regexp $target_triplet] {
77 unsupported $subdir/$src_code
78 return
81 if { [llength $args] > 0 } {
82 set comp_options [lindex $args 0]
83 } else {
84 set comp_options ""
87 set fail_message $subdir/$src_code
88 set pass_message $subdir/$src_code
90 if [info exists GROUP] {
91 if {[lsearch $groups $GROUP] == -1} {
92 return
96 if [string match $run yes] {
97 set actions run
100 set output_file "$tmpdir/[file tail [file rootname $src_code]]"
101 set assembly_file "$output_file"
102 append assembly_file ".S"
104 set compile_type "none"
106 case $actions {
107 compile
109 set compile_type "assembly"
110 set output_file $assembly_file
112 assemble
114 set compile_type "object"
115 append output_file ".o"
117 link
119 set compile_type "executable"
120 append output_file ".exe"
124 set compile_type "executable"
125 append output_file ".exe"
126 set run yes
128 default
130 set output_file ""
131 set compile_type "none"
135 set src_file "$srcdir/$subdir/$src_code"
136 set options ""
137 lappend options "compiler=$GCC_UNDER_TEST"
139 if { $comp_options != "" } {
140 lappend options "additional_flags=$comp_options"
143 set comp_output [gcc_target_compile $src_file $output_file $compile_type $options]
145 set pass no
147 # Delete things like "ld.so warning" messages.
148 set comp_output [prune_warnings $comp_output]
150 if [regexp -- $not_compiler_output $comp_output] {
151 if { $verbose > 1 } {
152 send_user "\nChecking:\n$not_compiler_output\nto make sure it does not match:\n$comp_output\nbut it does.\n\n"
153 } else {
154 send_log "\nCompiler output:\n$comp_output\n\n"
156 fail $fail_message
157 # The framework doesn't like to see any error remnants,
158 # so remove them.
159 uplevel {
160 if [info exists errorInfo] {
161 unset errorInfo
164 mike_cleanup $src_code $output_file $assembly_file
165 return
168 # remove any leftover CRs.
169 regsub -all -- "\r" $comp_output "" comp_output
171 regsub -all "(^|\n)\[^\n\]*linker input file unused since linking not done" $comp_output "" comp_output
172 regsub -all "(^|\n)\[^\n\]*file path prefix \[^\n\]* never used" $comp_output "" comp_output
174 set unsupported_message [${tool}_check_unsupported_p $comp_output]
175 if { $unsupported_message != "" } {
176 unsupported "$subdir/$src_code: $unsupported_message"
177 mike_cleanup $src_code $output_file $assembly_file
178 return
181 if { $verbose > 1 } {
182 send_user "\nChecking:\n$compiler_output\nto see if it matches:\n$comp_output\n"
183 } else {
184 send_log "\nCompiler output:\n$comp_output\n\n"
186 if [regexp -- $compiler_output $comp_output] {
187 if { $verbose > 1 } {
188 send_user "Yes, it matches.\n\n"
190 set pass yes
191 if [file exists [file rootname [file tail $src_code]].s] {
192 set fd [open [file rootname [file tail $src_code]].s r]
193 set dot_s [read $fd]
194 close $fd
195 if { $compiler_result != "" } {
196 verbose "Checking .s file for $compiler_result" 2
197 if [regexp -- $compiler_result $dot_s] {
198 verbose "Yes, it matches." 2
199 } else {
200 verbose "Nope, doesn't match." 2
201 verbose $dot_s 4
202 set pass no
205 if { $not_compiler_result != "" } {
206 verbose "Checking .s file for not $not_compiler_result" 2
207 if ![regexp -- $not_compiler_result $dot_s] {
208 verbose "Nope, not found (that's good)." 2
209 } else {
210 verbose "Uh oh, it was found." 2
211 verbose $dot_s 4
212 set pass no
216 if [string match $run yes] {
217 set result [gcc_load $output_file]
218 set status [lindex $result 0]
219 set output [lindex $result 1]
220 if { $status == -1 } {
221 mike_cleanup $src_code $output_file $assembly_file
222 return
224 if { $verbose > 1 } {
225 send_user "Checking:\n$program_output\nto see if it matches:\n$output\n\n"
227 if ![regexp -- $program_output $output] {
228 set pass no
229 if { $verbose > 1 } {
230 send_user "Nope, does not match.\n\n"
232 } else {
233 if { $verbose > 1 } {
234 send_user "Yes, it matches.\n\n"
238 } else {
239 if { $verbose > 1 } {
240 send_user "Nope, does not match.\n\n"
244 if [string match $pass "yes"] {
245 pass $pass_message
246 } else {
247 fail $fail_message
250 # The framework doesn't like to see any error remnants,
251 # so remove them.
252 uplevel {
253 if [info exists errorInfo] {
254 unset errorInfo
258 mike_cleanup $src_code $output_file $assembly_file