2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / lib / mike-g77.exp
blobccc9041e3ec395241faeabc6bfd295cf02571b89
1 # Copyright (C) 1988, 90, 91, 92, 95, 96, 97, 1998 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.
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 this program; if not, write to the Free Software
15 # Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # This file was derived from mike-g++.exp written by Mike Stump <mrs@cygnus.com>
19 # Please email any bugs, comments, and/or additions to this file to:
20 # fortran@gnu.org
23 # mike_cleanup -- remove any files that are created by the testcase
25 proc mike_cleanup { src_code output_file assembly_file } {
26 remote_file build delete $output_file $assembly_file;
30 # prebase -- sets up a Mike Stump (mrs@cygnus.com) style g77 test
32 proc prebase { } {
33 global compiler_output
34 global not_compiler_output
35 global compiler_result
36 global not_compiler_result
37 global program_output
38 global groups
39 global run
40 global actions
41 global target_regexp
43 set compiler_output "^$"
44 set not_compiler_output ".*Internal compiler error.*"
45 set compiler_result ""
46 set not_compiler_result ""
47 set program_output ".*PASS.*"
48 set groups {}
49 set run no
50 set actions assemble
51 set target_regexp ".*"
55 # run the test
57 proc postbase { src_code run groups args } {
58 global verbose
59 global srcdir
60 global subdir
61 global not_compiler_output
62 global compiler_output
63 global compiler_result
64 global not_compiler_result
65 global program_output
66 global actions
67 global target_regexp
68 global host_triplet
69 global target_triplet
70 global tool
71 global tmpdir
72 global G77_UNDER_TEST
73 global GROUP
75 if ![info exists G77_UNDER_TEST] {
76 error "No compiler specified for testing."
79 if ![regexp $target_regexp $target_triplet] {
80 unsupported $subdir/$src_code
81 return
84 if { [llength $args] > 0 } {
85 set comp_options [lindex $args 0];
86 } else {
87 set comp_options ""
90 set fail_message $subdir/$src_code
91 set pass_message $subdir/$src_code
93 if [info exists GROUP] {
94 if {[lsearch $groups $GROUP] == -1} {
95 return
99 if [string match $run yes] {
100 set actions run
103 set output_file "$tmpdir/[file tail [file rootname $src_code]]"
104 set assembly_file "$output_file"
105 append assembly_file ".S"
107 set compile_type "none"
109 case $actions {
110 compile
112 set compile_type "assembly";
113 set output_file $assembly_file;
115 assemble
117 set compile_type "object";
118 append output_file ".o";
120 link
122 set compile_type "executable";
123 append output_file ".exe";
127 set compile_type "executable";
128 append output_file ".exe";
129 set run yes;
131 default
133 set output_file "";
134 set compile_type "none";
138 set src_file "$srcdir/$subdir/$src_code"
139 set options ""
140 lappend options "compiler=$G77_UNDER_TEST"
142 if { $comp_options != "" } {
143 lappend options "additional_flags=$comp_options"
146 set comp_output [g77_target_compile $src_file $output_file $compile_type $options];
148 set pass no
150 # Delete things like "ld.so warning" messages.
151 set comp_output [prune_warnings $comp_output]
153 if [regexp -- $not_compiler_output $comp_output] {
154 if { $verbose > 1 } {
155 send_user "\nChecking:\n$not_compiler_output\nto make sure it does not match:\n$comp_output\nbut it does.\n\n"
156 } else {
157 send_log "\nCompiler output:\n$comp_output\n\n"
159 fail $fail_message
160 # The framework doesn't like to see any error remnants,
161 # so remove them.
162 uplevel {
163 if [info exists errorInfo] {
164 unset errorInfo
167 mike_cleanup $src_code $output_file $assembly_file
168 return
171 # remove any leftover CRs.
172 regsub -all -- "\r" $comp_output "" comp_output
174 regsub -all "(^|\n)\[^\n\]*linker input file unused since linking not done" $comp_output "" comp_output
175 regsub -all "(^|\n)\[^\n\]*file path prefix \[^\n\]* never used" $comp_output "" comp_output
177 set unsupported_message [${tool}_check_unsupported_p $comp_output]
178 if { $unsupported_message != "" } {
179 unsupported "$subdir/$src_code: $unsupported_message"
180 mike_cleanup $src_code $output_file $assembly_file
181 return
184 if { $verbose > 1 } {
185 send_user "\nChecking:\n$compiler_output\nto see if it matches:\n$comp_output\n"
186 } else {
187 send_log "\nCompiler output:\n$comp_output\n\n"
189 if [regexp -- $compiler_output $comp_output] {
190 if { $verbose > 1 } {
191 send_user "Yes, it matches.\n\n"
193 set pass yes
194 if [file exists [file rootname [file tail $src_code]].s] {
195 set fd [open [file rootname [file tail $src_code]].s r]
196 set dot_s [read $fd]
197 close $fd
198 if { $compiler_result != "" } {
199 verbose "Checking .s file for $compiler_result" 2
200 if [regexp -- $compiler_result $dot_s] {
201 verbose "Yes, it matches." 2
202 } else {
203 verbose "Nope, doesn't match." 2
204 verbose $dot_s 4
205 set pass no
208 if { $not_compiler_result != "" } {
209 verbose "Checking .s file for not $not_compiler_result" 2
210 if ![regexp -- $not_compiler_result $dot_s] {
211 verbose "Nope, not found (that's good)." 2
212 } else {
213 verbose "Uh oh, it was found." 2
214 verbose $dot_s 4
215 set pass no
219 if [string match $run yes] {
220 set result [g77_load $output_file]
221 set status [lindex $result 0];
222 set output [lindex $result 1];
223 if { $status == -1 } {
224 mike_cleanup $src_code $output_file $assembly_file;
225 return;
227 if { $verbose > 1 } {
228 send_user "Checking:\n$program_output\nto see if it matches:\n$output\n\n"
230 if ![regexp -- $program_output $output] {
231 set pass no
232 if { $verbose > 1 } {
233 send_user "Nope, does not match.\n\n"
235 } else {
236 if { $verbose > 1 } {
237 send_user "Yes, it matches.\n\n"
241 } else {
242 if { $verbose > 1 } {
243 send_user "Nope, does not match.\n\n"
247 if [string match $pass "yes"] {
248 pass $pass_message
249 } else {
250 fail $fail_message
253 # The framework doesn't like to see any error remnants,
254 # so remove them.
255 uplevel {
256 if [info exists errorInfo] {
257 unset errorInfo
261 mike_cleanup $src_code $output_file $assembly_file