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