Replace deprecated tcl case statements with switch statements
[deliverable/binutils-gdb.git] / gas / testsuite / gas / all / gas.exp
1 # Copyright (C) 2012-2020 Free Software Foundation, Inc.
2
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.
12 #
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, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
16
17 #
18 # These tests should be valid on all targets.
19 #
20
21 # I think currently all targets fail this one when listings are enabled.
22 gas_test "p2425.s" "" "" "pcrel values in assignment"
23
24 # p1480.s uses a ".space" directive which for most assemblers means
25 # "allocate some space". On the PA it means "switch into this space".
26 #
27 # Therefore this test (as it is currently written) is completely bogus
28 # for any PA target. Do not bother trying to run it and just claim
29 # it fails.
30 #
31 # The C54x uses ".space" to allocate bits, and requires absolute expressions;
32 # The ".space" directive is taken care of in the C54x-specific tests, so fail
33 # here
34 #
35 # The test also doesn't work on mep targets, since they use RELC, and it
36 # will avoid simplifying the expression since it conservatively assumes
37 # ugly expressions can be saved until link-time.
38 if { [istarget hppa*-*-*] || [istarget *c54x*-*-*] || [istarget mep*-*-*]} then {
39 setup_xfail *-*-*
40 fail "simplifiable double subtraction"
41 } else {
42 gas_test "p1480.s" "" "-a>" "simplifiable double subtraction"
43 }
44
45 # No floating point support in assembly code for CRIS and Z80.
46 if { ![istarget cris-*-*] && ![istarget crisv32-*-*]
47 && ![istarget z80-*-*] } then {
48 gas_test "float.s" "" "" "simple FP constants"
49 }
50
51 # This test is meaningless for the PA; the difference of two undefined
52 # symbols is something that is (and must be) supported on the PA.
53 # The same is true for ALPHA-VMS.
54 #
55 # The AVR, MICROBLAZE, MN10300, RL78 and RX ports all support link time
56 # relaxation, which in turn allows for link time resolution of the
57 # differences of two previously undefined symbols. Hence this test will
58 # not pass for these targets.
59 if { ![istarget alpha*-*-*vms*]
60 && ![istarget am3*-*-*]
61 && ![istarget avr-*-*]
62 && ![istarget ft32-*-*]
63 && ![istarget hppa*-*-*]
64 && ![istarget microblaze-*-*]
65 && ![istarget mn10300-*-*]
66 && ![istarget msp430*-*-*]
67 && ![istarget riscv*-*-*]
68 && ![istarget rl78-*-*]
69 && ![istarget rx-*-*] } then {
70 gas_test_error "diff1.s" "" "difference of two undefined symbols"
71 }
72
73 gas_test_error "equiv1.s" "" ".equiv for symbol already set to another one"
74 gas_test_error "equiv2.s" "" ".equiv for symbol already set to an expression"
75
76 # The inode comparison used to detect identical input and output files
77 # doesn't work on non-Posix hosts.
78 if { ![ishost "*-*-mingw*"] } then {
79 gas_test_error "none.s" "-o $srcdir/$subdir/none.s" "Output file must be distinct from input"
80 }
81
82 # .equ works differently on some targets.
83 switch -glob $target_triplet {
84 hppa*-*-* { }
85 *c54x*-*-* { }
86 default {
87 gas_test "equ-ok.s" "" "" ".equ for symbol already set"
88 gas_test_error "equ-bad.s" "" ".equ for symbol already set through .eqv"
89 }
90 }
91
92 gas_test "eqv-ok.s" "" "" ".eqv support"
93 gas_test_error "eqv-bad.s" "" ".eqv for symbol already set"
94 run_dump_test eqv-dot
95
96 if { ![istarget "bfin-*-*"] } then {
97 gas_test "assign-ok.s" "" "" "== assignment support"
98 }
99 gas_test_error "assign-bad.s" "" "== assignment for symbol already set"
100
101 run_dump_test simple-forward
102 run_dump_test forward
103
104 # aout relocs are often weird, so is mep. don't bother testing
105 # som doesn't use a .text section
106 # mmix doesn't like .L1:
107 # ti addresses aren't octets.
108 if { ![is_aout_format] } {
109 switch -glob $target_triplet {
110 hppa*64*-*-* {
111 run_dump_test fwdexp
112 }
113 alpha-*-*linux*ecoff { }
114 alpha-*-osf* { }
115 hppa*-*-hpux* { }
116 mep-*-* { }
117 mmix-*-* { }
118 nds32*-*-* { }
119 tic30*-*-* { }
120 tic4x*-*-* { }
121 tic54x*-*-* { }
122 default {
123 run_dump_test fwdexp
124 }
125 }
126 }
127
128 # .set works differently on some targets.
129 # most of the tests won't work on targets that set linkrelax.
130 # 4 octet bytes confuse address matching on ti targets.
131 # pdp11 gets unexpected reloc types.
132 switch -glob $target_triplet {
133 alpha*-*-* { }
134 am3*-*-* { }
135 cr16*-*-* { }
136 crx*-*-* { }
137 h8300-*-* { }
138 mips*-*-* { }
139 mn10200-*-* { }
140 mn10300-*-* { }
141 msp430*-*-* { }
142 nds32*-*-* { }
143 pdp11-*-* { }
144 tic30*-*-* { }
145 tic4x*-*-* { }
146 tic54x*-*-* { }
147 xtensa*-*-* { }
148 z80-*-* { }
149 default {
150 run_dump_test redef
151 # These targets fail redef2 because they disallow redefined
152 # symbols on relocs.
153 setup_xfail "m68hc1*-*-*" "m6811-*-*" "m6812-*-*" "rl78-*-*"
154 setup_xfail "riscv*-*-*" "rx-*-*" "vax*-*-*" "xgate*-*-*" "z8k-*-*"
155 run_dump_test redef2
156 setup_xfail "m68hc1*-*-*" "m6811-*-*" "m6812-*-*" "rl78-*-*"
157 setup_xfail "riscv*-*-*" "rx-*-*" "vax*-*-*" "xgate*-*-*" "z8k-*-*"
158 # rs6000-aix disallows redefinition via .comm.
159 setup_xfail "*-*-aix*"
160 # These targets fail redef3 because section contents for the
161 # word referencing the .comm sym is not zero and/or its reloc
162 # has a non-zero addend. Relaxing the test would hide real
163 # failures.
164 setup_xfail "bfin-*-*" "i\[3-7\]86-*-*coff" \
165 "i\[3-7\]86-*-*pe" "i\[3-7\]86-*-go32*" \
166 "i\[3-7\]86-*-cygwin*" "i\[3-7\]86-*-mingw*" \
167 "x86_64-*-cygwin*" "x86_64-*-mingw*"
168 run_dump_test redef3
169 gas_test_error "redef4.s" "" ".set for symbol already used as label"
170 gas_test_error "redef5.s" "" ".set for symbol already defined through .comm"
171 }
172 }
173
174 proc do_comment {} {
175 set testname "comment.s: comments in listings"
176 set x1 0
177 set x2 0
178 set x3 0
179 set white {[ \t]*}
180 gas_start "comment.s" "-al"
181 while 1 {
182 # Apparently CRLF is received when using ptys for subprocesses; hence the
183 # \r\n for line 3.
184 expect {
185 -re "^ +1\[ \t\]+# This\[^\n\]*\n" { set x1 1 }
186 -re "^ +2\[ \t\]+# correctly\[^\n\]*\n" { set x2 1 }
187 -re "^ +3\[ \t\]+/. C comments too. ./\r?\r?\n" { set x3 1 }
188 -re "\[^\n\]*\n" { }
189 timeout { perror "timeout\n"; break }
190 eof { break }
191 }
192 }
193 gas_finish
194 if [all_ones $x1 $x2 $x3] then { pass $testname } else { fail $testname }
195 }
196
197 do_comment
198
199 # This test checks the output of the -ag switch. It must detect at least
200 # the name of the input file, output file, and options passed.
201 proc general_info_section {} {
202 set testname "general info section in listings"
203 set x1 0
204 set x2 0
205 set x3 0
206 set white {[ \t]*}
207 gas_start "comment.s" "-agn"
208 while 1 {
209 expect {
210 -re "^ \[^\n\]*\t: .*\-agn\[^\n\]*\n" { set x1 1 }
211 -re "^ \[^\n\]*\t: \[^\n\]*comment\.s\[^\n\]*\n" { set x2 1 }
212 -re "^ \[^\n\]*\t: a\.out\[^\n\]*\n" { set x3 1 }
213 -re "\[^\n\]*\n" { }
214 timeout { perror "timeout\n"; break }
215 eof { break }
216 }
217 }
218 gas_finish
219 if [all_ones $x1 $x2 $x3] then { pass $testname } else { fail $testname }
220 }
221
222 general_info_section
223
224 #
225 # Test x930509a -- correct assembly of differences involving forward
226 # references.
227 #
228
229 proc do_930509a {} {
230 set testname "difference between forward references"
231 set x 0
232 gas_start "x930509.s" "-al"
233 while 1 {
234 # We need to accommodate both byte orders here.
235 # If ".long" means an 8-byte value on some target someday, this test will have
236 # to be fixed.
237 expect {
238 -re "^ +1 .... 00 ?00 ?00 ?00" { fail $testname; set x 1 }
239 -re "^ +1 .... 04 ?00 ?00 ?00" { pass $testname; set x 1 }
240 -re "^ +1 .... 00 ?00 ?00 ?04" { pass $testname; set x 1 }
241 -re "\[^\n\]*\n" { }
242 timeout { perror "timeout\n"; break }
243 eof { break }
244 }
245 }
246 gas_finish
247 if !$x then { fail $testname }
248 }
249
250 # This test is meaningless for the PA and CR16/CRX: the difference of two
251 # symbols cannot be resolved by the assembler.
252 # C54x assembler (for compatibility) does not allow differences between
253 # forward references.
254 # C30 counts a four byte offset as a difference of one.
255 if { ![istarget *c30*-*-*]
256 && ![istarget *c4x*-*-*]
257 && ![istarget *c54x*-*-*]
258 && ![istarget cr16*-*-*]
259 && ![istarget crx*-*-*]
260 && ![istarget ft32-*-*]
261 && ![istarget h8300*-*-*]
262 && ![istarget hppa*-*-*] } then {
263 # The vax fails because VMS can apparently actually handle this
264 # case in relocs, so gas doesn't handle it itself.
265 # msp430, mn10[23]00 and riscv emit two relocs to handle the difference of two symbols.
266 setup_xfail "am3*-*-*" "mn10200-*-*" "mn10300*-*-*" "msp430*-*-*" "riscv*-*-*" "vax*-*-vms*"
267 do_930509a
268 }
269
270 # ".struct" and ".align" have different meanings on c54x
271 # These directives are done in the c54x-specific tests instead
272 switch -glob $target_triplet {
273 hppa*-*-* { }
274 *c4x*-*-* { }
275 *c54x*-*-* { }
276 default {
277 run_dump_test struct
278 run_dump_test align
279 run_dump_test align2
280 }
281 }
282
283 # '<' and '>' appear to have special meanings on the excluded targets
284 switch -glob $target_triplet {
285 frv-*-* { }
286 hppa*-*-* { }
287 m32r-*-* { }
288 mmix-*-* { }
289 *c4x*-*-* { }
290 *c54x*-*-* { }
291 bfin-*-* { }
292 default {
293 run_dump_test altmacro
294 # The second test is valid only when '!' is not a comment
295 # character (it is allowed to be a line comment character).
296 if [string match "" [lindex [gas_run excl.s "-o /dev/null" ""] 0]] {
297 run_dump_test altmac2
298 # Similarly this test does not work when ! is a line separator.
299 run_dump_test eval
300 }
301 }
302 }
303
304 # This test is for any COFF target.
305 # We omit the ARM toolchains because they define locals to
306 # start with '.', which eliminates .eos, .text etc from the output.
307 # Omit c54x, since .tag and .def mean something different on that target
308 if { ([istarget *-*-coff*] && ![istarget arm*-*-coff] && ![istarget *c4x*-*-coff] && ![istarget *c54x*-*-coff]) \
309 ||([istarget *-*-pe*] && ![istarget arm*-*-pe*]) \
310 || [istarget i*86-*-aix*] \
311 || [istarget i*86-*-sco*] \
312 || [istarget i*86-*-isc*] \
313 || [istarget i*86-*-go32*] \
314 || [istarget i*86-*-cygwin*] \
315 || [istarget x86_64-*-mingw*] \
316 || [istarget i*86-*-*nt] \
317 || [istarget i*86-*-interix*] } {
318 run_dump_test cofftag
319 }
320
321 # Test omitting conditionals from listings.
322 proc test_cond {} {
323 global comp_output
324 global srcdir
325 global subdir
326
327 set testname "conditional listings"
328 gas_run cond.s "-alc" ">dump.out"
329 if ![string match "" $comp_output] {
330 send_log "$comp_output\n"
331 fail $testname
332 } else {
333 if { [regexp_diff dump.out $srcdir/$subdir/cond.l] } {
334 fail $testname
335 } else {
336 pass $testname
337 }
338 }
339 }
340
341 # This test is not suitable for the PA for various reasons
342 # not limited to the fact that it depends on specific section
343 # names appearing in the output file.
344 # Again, p2align doesn't work on c54x and related targets.
345 switch -glob $target_triplet {
346 alpha-*-linux*ecoff { }
347 alpha-*-osf* { }
348 hppa*-*-* { }
349 *c4x*-*-* { }
350 *c54x*-*-* { }
351 rl78-*-* { }
352 rx-*-* { }
353 default {
354 test_cond
355 remote_download host "$srcdir/$subdir/incbin.dat"
356 run_dump_test incbin
357 }
358 }
359
360 if { ([istarget "i*86-*-*pe*"] && ![istarget "i*86-*-openbsd*"]) \
361 || [istarget "i*86-*-cygwin*"] \
362 || [istarget "i*86-*-mingw32*"] } {
363 gas_test "fastcall.s" "" "" "fastcall labels"
364 }
365
366 if { ![istarget "bfin-*-*"] && ![istarget "nds32*-*-*"] } then {
367 run_dump_test assign
368 }
369 run_dump_test sleb128
370 run_dump_test sleb128-2
371 run_dump_test sleb128-3
372 run_dump_test sleb128-4
373 run_dump_test sleb128-5
374 # .byte is not 8 bits on either tic4x or tic54x
375 if { ![istarget "tic4x*-*-*"] && ![istarget "tic54x*-*-*"] } {
376 run_dump_test sleb128-7
377 run_dump_test sleb128-8
378 }
379 run_dump_test sleb128-9
380
381 # .byte is 32 bits on tic4x, and .p2align isn't supported on tic54x
382 # .space is different on hppa*-hpux.
383 # MeP put bytes into packets.
384 if { ![istarget "tic4x*-*-*"] && ![istarget "tic54x*-*-*"] && ![istarget "hppa*-*-hpux*"] && ![istarget "mep*-*-*"] } {
385 run_dump_test relax
386 }
387
388 # powerpc and s390 allow a string argument to .byte
389 if { ![istarget "powerpc*-*-*"] && ![istarget "rs6000*-*-*"] && ![istarget "s390*-*-*"] } {
390 run_dump_test byte
391 }
392
393 run_dump_test quad
394 run_dump_test octa
395
396 # .set works differently on some targets.
397 switch -glob $target_triplet {
398 alpha*-*-* { }
399 mips*-*-* { }
400 *c54x*-*-* { }
401 z80-*-* { }
402 default {
403 run_dump_test weakref1
404 run_dump_test weakref1g
405 run_dump_test weakref1l
406 run_dump_test weakref1u
407 run_dump_test weakref1w
408 }
409 }
410 gas_test_error "weakref2.s" "" "e: would close weakref loop: e => a => b => c => d => e"
411 gas_test_error "weakref3.s" "" "a: would close weakref loop: a => b => c => d => e => a"
412 gas_test_error "weakref4.s" "" "is already defined"
413
414 run_dump_test string
415 if [is_elf_format] {
416 run_dump_test none
417 }
418
419 run_dump_test quoted-sym-names
420
421 run_list_test pr20312
422
423 load_lib gas-dg.exp
424 dg-init
425 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" ""
426 dg-finish
427
428 # Set $nop_type appropriately to indicate the NOP instruction mnemonic.
429 switch -glob $target_triplet {
430 bpf-*-* {
431 set nop_type 6
432 }
433 mmix-*-* {
434 set nop_type 5
435 }
436 or1k*-*-* {
437 set nop_type 2
438 }
439 ia64-*-* {
440 set nop_type 1
441 }
442 default {
443 set nop_type 0
444 }
445 }
446 run_dump_test "org-1" [list [list as "--defsym nop_type=$nop_type"]]
447 run_dump_test "org-2"
448 run_dump_test "org-3"
449 run_dump_test "org-4"
450 run_dump_test "org-5"
451 run_dump_test "org-6"
452
453 run_dump_test "fill-1"
454
455 gas_test "pr23938.s" "" "" ".xstabs"
This page took 0.039283 seconds and 4 git commands to generate.