2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / treelang / treetests.exp
blob42ceb242d468c16e5a40d23966861dcd5f9baa50
2 # Tests for treelang; run from gcc/treelang/Make-lang.in => gcc/Makefile
3 # find ttt for the actual tests
5 # Copyright (C) 1999, 2000, 2001, 2002 by The Free Software Foundation
7 # This program is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by the
9 # Free Software Foundation; either version 2, or (at your option) any
10 # later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, 59 Temple Place - Suite 330,
20 # Boston, MA 02111-1307, USA.
22 # In other words, you are welcome to use, share and improve this program.
23 # You are forbidden to forbid anyone else to use, share and improve
24 # what you give them. Help stamp out software-hoarding!
26 # Check the pgm is even there and set up the basics
27 proc init_utility {pgm} {
28 global transform
29 global pgm_actual
30 global pgm_base
31 global fix_progname
32 global path
33 # maybe add "X" to front of fail to say it is an expected failure
34 global X
36 set pgm_base ${pgm}
37 set pgm_actual ${pgm}
39 if { ${transform} != "s,x,x,"} {
40 verbose "1. program name was ${pgm}" 2
41 set sed_rc [catch {eval exec sed -e "${transform}" <<${pgm} } catch_res]
42 if { ${sed_rc} != "0" } {
43 verbose "2. Program name transform failed rc=${sed_rc} stat=${catch_res}" 1
44 ${X}fail "${pgm} sed"
45 return 0
47 set pgm_actual ${catch_res}
48 verbose "3. program name after transformation is ${pgm_actual}" 2
51 set which_rc [catch {exec which ${pgm_actual}} stat]
52 if { ${which_rc} != "0" } {
53 verbose "4. ${pgm_base} cannot be found rc=${which_rc} stat=${stat}" 1
54 ${X}fail "${pgm} = ${pgm_actual} not found in path (${path})"
55 return 0
57 set fix_progname "s,${pgm_actual},${pgm_base},"
58 verbose "5. fix program name value = ${fix_progname}" 4
59 return 1
62 #run pgm, option to remove file names from outputs
63 proc run3 {srcdd testdd parms group_nbr item_nbr nonzero_RC_expected check_file sanitize_output tree1 pipe} {
65 global transform
66 global pgm_actual
67 global pgm_base
68 global fix_progname
69 global X
70 global extras
72 set error_msg 0
73 set basefile "a${group_nbr}${pgm_base}.out${item_nbr}"
74 set infile ""
75 set outfile ""
76 set suffix ""
77 set temp_extras "-O3 "
78 set real_pgm_actual ${pgm_actual}
80 if {${tree1} > 0} {
81 if {"${pgm_actual}" == "gcc"} {
82 set real_pgm_actual "xgcc"
83 set temp_extras "${extras}"
85 set infile "${srcdd}/a${group_nbr}${pgm_base}i${item_nbr}.tree"
86 set mainfile "${srcdd}/a${group_nbr}${pgm_base}i${item_nbr}.c"
87 set outfile "-o ${testdd}/a${group_nbr}${pgm_base}o${item_nbr}${suffix}"
90 verbose "6. exec ${real_pgm_actual} ${temp_extras} ${parms} ${mainfile} ${infile} ${outfile} >${testdd}/${basefile} 2>${testdd}/${basefile}err" 2
91 set run_rc [catch {eval exec ${real_pgm_actual} ${temp_extras} ${parms} ${mainfile} ${infile} ${outfile} >${testdd}/${basefile} 2>${testdd}/${basefile}err} catch_res]
92 if {${run_rc} == 1} {
93 if {${nonzero_RC_expected} == 0} {
94 verbose "7. ${real_pgm_actual} ${group_nbr} ${item_nbr} failed due to rc=${run_rc} status=${catch_res}" 1
95 ${X}fail "${pgm_base} ${group_nbr} ${item_nbr} rc!=0"
96 return
98 } else {
99 if {${nonzero_RC_expected} == 1} {
100 verbose "8. ${pgm_actual} ${group_nbr} ${item_nbr} failed - did not produce nonzero return code as expected rc=${run_rc} status=${catch_res}" 1
101 ${X}fail "${pgm_base} ${group_nbr} ${item_nbr} rc=0"
102 return
106 # change the filenames to (file) in output if needed to allow testing
107 set checkfile1 "${srcdd}/${basefile}"
108 set checkfile2 "${testdd}/${basefile}"
109 if {${sanitize_output} != 0} {
110 set oldcheckfile1 "${checkfile1}"
111 set oldcheckfile2 "${checkfile2}"
112 set checkfile1 "${testdd}/${basefile}.test.nofilename"
113 set checkfile2 "${testdd}/${basefile}.run.nofilename"
114 set run_rc [catch {eval exec sed -f ${srcdd}/filefix.sed <${oldcheckfile1} >${checkfile1}} catch_res]
115 if {${run_rc} == 1} {
116 verbose "9. sed to cleanup filenames (std 1) in pgm output failed due to rc=${run_rc} status=${catch_res}" 1
117 if {${error_msg} == 0} {
118 set error_msg "9. sed to cleanup filenames (std 1) in pgm output failed due to rc=${run_rc} status=${catch_res}"
121 set run_rc [catch {eval exec sed -f ${srcdd}/filefix.sed <${oldcheckfile2} | sed -e "${fix_progname}" >${checkfile2}} catch_res]
122 if {${run_rc} == 1} {
123 verbose "10. sed to cleanup filenames (std 2) in pgm output failed due to rc=${run_rc} status=${catch_res}" 1
124 if {${error_msg} == 0} {
125 set error_msg "10. sed to cleanup filenames (std 2) in pgm output failed due to rc=${run_rc} status=${catch_res}"
129 set diff [diff ${checkfile1} ${checkfile2}]
130 if {${diff} != 1} {
131 verbose "11. ${pgm_actual} ${group_nbr} ${item_nbr} diff stdout failed rc=${diff}" 1
132 if {${error_msg} == 0} {
133 set error_msg "11. ${pgm_actual} ${group_nbr} ${item_nbr} diff stdout failed rc=${diff}"
137 set checkfile1 "${srcdd}/${basefile}err"
138 set checkfile2 "${testdd}/${basefile}err"
139 if {${sanitize_output} != 0} {
140 set oldcheckfile1 "${checkfile1}"
141 set oldcheckfile2 "${checkfile2}"
142 set checkfile1 "${testdd}/${basefile}err.test.nofilename"
143 set checkfile2 "${testdd}/${basefile}err.run.nofilename"
144 set run_rc [catch {eval exec sed -f ${srcdd}/filefix.sed <${oldcheckfile1} >${checkfile1}} catch_res]
145 if {${run_rc} == 1} {
146 verbose "12. sed to cleanup filenames (err 1) in pgm output failed due to rc=${run_rc} status=${catch_res}" 1
147 if {${error_msg} == 0} {
148 set error_msg "12. sed to cleanup filenames (err 1) in pgm output failed due to rc=${run_rc} status=${catch_res}"
151 set run_rc [catch {eval exec sed -f ${srcdd}/filefix.sed <${oldcheckfile2} | sed -e "${fix_progname}" >${checkfile2}} catch_res]
152 if {${run_rc} == 1} {
153 verbose "13. sed to cleanup filenames (err 2) in pgm output failed due to rc=${run_rc} status=${catch_res}" 1
154 if {${error_msg} == 0} {
155 set error_msg "13. sed to cleanup filenames (err 2) in pgm output failed due to rc=${run_rc} status=${catch_res}"
159 set diff [diff ${checkfile1} ${checkfile2}]
160 if {${diff} != 1} {
161 verbose "14. ${pgm_actual} ${group_nbr} ${item_nbr} diff stderr failed rc=${diff}" 1
162 if {${error_msg} == 0} {
163 set error_msg "14. ${pgm_actual} ${group_nbr} ${item_nbr} diff stderr failed rc=${diff}"
167 if {${check_file} >0} {
168 if {${tree1} == 0} {
169 set checkfile1 "${srcdd}/${basefile}file"
170 set checkfile2 "${testdd}/${basefile}file"
171 if {${sanitize_output} != 0} {
172 set oldcheckfile1 "${checkfile1}"
173 set oldcheckfile2 "${checkfile2}"
174 set checkfile1 "${testdd}/${basefile}file.test.nofilename"
175 set checkfile2 "${testdd}/${basefile}file.run.nofilename"
176 set run_rc [catch {eval exec sed -f ${srcdd}/filefix.sed <${oldcheckfile1} >${checkfile1}} catch_res]
177 if {${run_rc} == 1} {
178 verbose "15. sed to cleanup filenames (err 1) in pgm stdout failed due to rc=${run_rc} status=${catch_res}" 1
179 if {${error_msg} == 0} {
180 set error_msg "15. sed to cleanup filenames (err 1) in pgm stdout failed due to rc=${run_rc} status=${catch_res}"
183 set run_rc [catch {eval exec sed -f ${srcdd}/filefix.sed <${oldcheckfile2} | sed -e "${fix_progname}" >${checkfile2}} catch_res]
184 if {${run_rc} == 1} {
185 verbose "16. sed to cleanup filenames (err 2) in pgm stdout failed due to rc=${run_rc} status=${catch_res}" 1
186 if {${error_msg} == 0} {
187 set error_msg "16. sed to cleanup filenames (err 2) in pgm stdout failed due to rc=${run_rc} status=${catch_res}"
191 set diff [diff ${checkfile1} ${checkfile2}]
192 if {${diff} != 1} {
193 verbose "17. ${pgm_actual} ${group_nbr} ${item_nbr} diff stdout file failed rc=${diff}" 1
194 if {${error_msg} == 0} {
195 set error_msg "17. ${pgm_actual} ${group_nbr} ${item_nbr} diff stdout file failed rc=${diff}"
201 if {${check_file} >1} {
202 if {${tree1} == 0} {
203 set checkfile1 "${srcdd}/${outfile}"
204 set checkfile2 "${testdd}/${outfile}"
205 if {${sanitize_output} != 0} {
206 set oldcheckfile1 "${checkfile1}"
207 set oldcheckfile2 "${checkfile2}"
208 set checkfile1 "${testdd}/${basefile}out.test.nofilename"
209 set checkfile2 "${testdd}/${basefile}out.run.nofilename"
210 set run_rc [catch {eval exec sed -f ${srcdd}/filefix.sed <${oldcheckfile1} >${checkfile1}} catch_res]
211 if {${run_rc} == 1} {
212 verbose "18. sed to cleanup filenames (err 1) in pgm output failed due to rc=${run_rc} status=${catch_res}" 1
213 if {${error_msg} == 0} {
214 set error_msg "18. sed to cleanup filenames (err 1) in pgm output failed due to rc=${run_rc} status=${catch_res}"
217 set run_rc [catch {eval exec sed -f ${srcdd}/filefix.sed <${oldcheckfile2} | sed -e "${fix_progname}" >${checkfile2}} catch_res]
218 if {${run_rc} == 1} {
219 verbose "19. sed to cleanup filenames (err 2) in pgm output failed due to rc=${run_rc} status=${catch_res}" 1
220 if {${error_msg} == 0} {
221 set error_msg "19. sed to cleanup filenames (err 2) in pgm output failed due to rc=${run_rc} status=${catch_res}"
225 set diff [diff ${checkfile1} ${checkfile2}]
226 if {${diff} != 1} {
227 verbose "20. ${pgm_actual} ${group_nbr} ${item_nbr} diff output file failed rc=${diff}" 1
228 if {${error_msg} == 0} {
229 set error_msg "20. ${pgm_actual} ${group_nbr} ${item_nbr} diff output file failed rc=${diff}"
235 if {${check_file} >2} {
236 set outfile "a${group_nbr}${pgm_base}o${item_nbr}${suffix}"
237 set pgmrun "${testdd}/a${group_nbr}${pgm_base}o${item_nbr}${suffix}"
238 set checkfile1 "${srcdd}/${outfile}runpgm"
239 set checkfile2 "${testdd}/${outfile}runpgm"
240 verbose "21. exec ${pgmrun} >${checkfile2} 2>${checkfile2}err" 2
241 set run_rc [catch {eval exec ${pgmrun} >${checkfile2} 2>${checkfile2}err} catch_res]
242 if {${run_rc} == 1} {
243 if {${nonzero_RC_expected} == 0} {
244 verbose "22. ${pgm_actual} ${group_nbr} ${item_nbr} failed due to rc=${run_rc} status=${catch_res}" 1
245 ${X}fail "${pgm_base} ${group_nbr} ${item_nbr} run"
246 return
248 } else {
249 if {${nonzero_RC_expected} == 1} {
250 verbose "23. ${pgm_actual} ${group_nbr} ${item_nbr} failed - did not produce nonzero return code as expected rc=${run_rc} status=${catch_res}" 1
251 ${X}fail "${pgm_base} ${group_nbr} ${item_nbr} run"
252 return
255 set diff [diff ${checkfile1} ${checkfile2}]
256 if {${diff} != 1} {
257 verbose "24. ${pgm_actual} ${group_nbr} ${item_nbr} diff run output file failed rc=${diff}" 1
258 if {${error_msg} == 0} {
259 set error_msg "24. ${pgm_actual} ${group_nbr} ${item_nbr} diff run output file failed rc=${diff}"
262 set diff [diff ${checkfile1}err ${checkfile2}err]
263 if {${diff} != 1} {
264 verbose "25. ${pgm_actual} ${group_nbr} ${item_nbr} diff run stderr file failed rc=${diff}" 1
265 if {${error_msg} == 0} {
266 set error_msg "25. ${pgm_actual} ${group_nbr} ${item_nbr} diff run stderr file failed rc=${diff}"
271 if {${error_msg}>0} {
272 ${X}fail "${pgm_base} ${group_nbr} ${item_nbr} fail code=${error_msg}"
273 } else {
274 pass "${pgm_base} ${group_nbr} ${item_nbr}"
276 return
279 set extras "$env(gcc_extras)"
280 set path $env(PATH)
281 set transform $env(TRANSFORM)
282 set srcdir $env(srcdir)
283 verbose "source directory ${srcdir}\n" 2
284 verbose "transform ${transform}\n" 2
285 set sourcedir "${srcdir}/testsuite/treelang"
286 set testdir "treelang"
288 set pgm_actual ""
290 # srcdd testdd parms group_nbr item_nbr nonzero_RC_expected check_file sanitize_output tree1
292 # ttt
294 #GCC - main C compiler tests via GCC
296 set X ""
298 set check_rc [init_utility "gcc"]
300 if {${check_rc} == 1} {
302 #set X "x"
303 set X ""
304 run3 "${sourcedir}" "${testdir}" " -g -O3 --param ggc-min-heapsize=0 --param ggc-min-expand=0 " 01 01 0 3 0 1 0
305 set X ""