Upload Tizen:Base source
[external/binutils.git] / gas / testsuite / gas / hppa / parse / parse.exp
1 # Copyright (C) 1993, 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2009
2 # Free Software Foundation, Inc.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  
17
18 # Please email any bugs, comments, and/or additions to this file to:
19 # dejagnu@gnu.org
20
21 # Written by the Center for Software Science at the University of Utah
22 # and by Cygnus Support.
23
24 proc do_string_tests {} {
25     set testname "stringer.s: Test embedded quotes and octal escapes in strings"
26     set x 0
27
28     gas_start "stringer.s" "-al"
29
30     # Instead of having a variable for each match string just increment the
31     # total number of matches seen.  That's simpler when testing large numbers
32     # of instructions (as these tests to).
33     while 1 {
34         expect {
35             -re "^ +\[0-9\]+ 0000 23696E63\[^\n\]*\n"   { set x [expr $x+1] }
36             -re "^ +\[0-9\]+      6C756465\[^\n\]*\n"   { set x [expr $x+1] }
37             -re "^ +\[0-9\]+      6B2E6465\[^\n\]*\n"   { set x [expr $x+1] }
38             -re "^ +\[0-9\]+      66220A00\[^\n\]*\n"   { set x [expr $x+1] }
39             -re "^ +\[0-9\]+ 0014 09307831\[^\n\]*\n"   { set x [expr $x+1] }
40             -re "^ +\[0-9\]+      3233\[^\n\]*\n"       { set x [expr $x+1] }
41             -re "\[^\n\]*\n"                            { }
42             timeout                             { perror "timeout\n"; break }
43             eof                                 { break }
44         }
45     }
46
47     # This was intended to do any cleanup necessary.  It kinda looks like it
48     # isn't needed, but just in case, please keep it in for now.
49     gas_finish
50
51     # Did we find what we were looking for?  If not, flunk it.
52     if [expr $x==6] then { pass $testname } else { fail $testname }
53 }
54
55 proc do_lsel_test {} {
56     set testname "lselbugs.s: lselbug"
57     set x 0
58
59     gas_start "lselbug.s" "-al"
60
61     # Make sure we correctly handle field selectors. 
62     while 1 {
63         expect {
64             -re "^ +\[0-9\]+ 0000 22A04000\[^\n\]*\n"   { set x [expr $x+1] }
65             -re "^ +\[0-9\]+ 0004 36B50100\[^\n\]*\n"   { set x [expr $x+1] }
66             -re "^ +\[0-9\]+ 0008 22A04000\[^\n\]*\n"   { set x [expr $x+1] }
67             -re "^ +\[0-9\]+ 000c 36B50100\[^\n\]*\n"   { set x [expr $x+1] }
68             -re "\[^\n\]*\n"                            { }
69             timeout                             { perror "timeout\n"; break }
70             eof                                 { break }
71         }
72     }
73
74     # This was intended to do any cleanup necessary.  It kinda looks like it
75     # isn't needed, but just in case, please keep it in for now.
76     gas_finish
77
78     # Did we find what we were looking for?  If not, flunk it.
79     if [expr $x==4] then { pass $testname } else { fail $testname }
80 }
81
82 proc do_valid_align_tests {} {
83     set testname "align1.s: valid alignment tests"
84     set x 0
85
86     gas_start "align1.s" "-al"
87
88     # Make sure we correctly handle field selectors. 
89     while 1 {
90         expect {
91             -re "^ +\[0-9\]+ 0000 08000240\[^\n\]*\n"   { set x [expr $x+1] }
92             -re "^ +\[0-9\]+ 0008 08000240\[^\n\]*\n"   { set x [expr $x+1] }
93             -re "^ +\[0-9\]+ 1000 08000240\[^\n\]*\n"   { set x [expr $x+1] }
94             -re "^ +\[0-9\]+ 0000\[^\n\]*BLOCK\[^\n\]*1024\[^\n\]*\n"
95                 { set x [expr $x+1] }
96             -re "^ +\[0-9\]+ 0400\[^\n\]*BLOCK\[^\n\]*1024\[^\n\]*\n"
97                 { set x [expr $x+1] }
98             -re "^ +\[0-9\]+ 0800\[^\n\]*BLOCK\[^\n\]*4\[^\n\]*\n"
99                 { set x [expr $x+1] }
100             -re "^ +\[0-9\]+ 0804\[^\n\]*ALIGN\[^\n\]*8\[^\n\]*\n"
101                 { set x [expr $x+1] }
102             -re "^ +\[0-9\]+ 0808\[^\n\]*BLOCK\[^\n\]*30\[^\n\]*\n"
103                 { set x [expr $x+1] }
104             -re "^ +\[0-9\]+ 0826\[^\n\]*ALIGN\[^\n\]*4\[^\n\]*\n"
105                 { set x [expr $x+1] }
106             -re "^ +\[0-9\]+ 0828\[^\n\]*BLOCK\[^\n\]*4\[^\n\]*\n"
107                 { set x [expr $x+1] }
108             -re "\[^\n\]*\n"                            { }
109             timeout                             { perror "timeout\n"; break }
110             eof                                 { break }
111         }
112     }
113
114     # This was intended to do any cleanup necessary.  It kinda looks like it
115     # isn't needed, but just in case, please keep it in for now.
116     gas_finish
117
118     # Did we find what we were looking for?  If not, flunk it.
119     if [expr $x==10] then { pass $testname } else { fail $testname }
120 }
121
122 if [istarget hppa*-*-*] then {
123     if { ![istarget hppa*-*-linux*] 
124          && ![istarget hppa*-*-netbsd*] } {
125         # GAS-2.0 does not always parse ! as a line separator when it should.
126         setup_xfail hppa*-*-*
127     }
128     gas_test "linesepbug.s" "" "" "line separator bug"
129
130     # Make sure GAS accepts syntax for accessing static data.
131     gas_test "global.s" "" "" "check for sym-\$global\$ acceptance"
132
133     # GAS-2.0 (and 1.36 for that matter) can not handle a .proc which
134     # has no label before it.
135     gas_test "procbug.s" "" "" "Label following .proc"
136
137     # One is required to explicitly IMPORT any non-local symbol used
138     # in an assembly file.  Make sure we give an error if we use
139     # an undefined symbol.
140     setup_xfail hppa*-*-*
141     gas_test_error "undefbug.s" "" "Check for error when using undefined symbol"
142
143     # This file has code and assembler directives before switching into any
144     # space/subspace pair.  This should report an error for SOM (it is not
145     # an error for ELF.  The file also has mismatched entry/exit and
146     # proc/procend pairs which are errors for both SOM and ELF.
147     gas_test_error "nosubspace.s" "" "Check for error(s) in input file "
148
149     # This file should return errors for both the ENTRY_GR and ENTRY_FR
150     # directives (they are out-of-range)
151     gas_test_error "entrybug.s" "" "Check for error on entry_gr and entry_fr"
152
153     # Make sure embedded quotes and octal escapes in strings work
154     do_string_tests
155
156     # Make sure we do not die on a .version directive
157     gas_test "versionbug.s" "" "" ".version directive"
158
159     # Make sure we give an error on a bogus .space directive.
160     # recent version of gas2 went into infinite loops printing
161     # errors on this test.
162     gas_test_error "spacebug.s" "" "Check for error on bogus .space directive"
163
164     # GAS should give an error for this test.
165     gas_test_error "calldatabug.s" "" "Check for invalid aguments on .call"
166
167     # Old versions of gas incorrectly gave errors on some valid .EXPORT lines
168     gas_test "exportbug.s" "" "" "syntax check for an old .EXPORT bug"
169
170     # Old versions of gas choked on this file for some reason
171     gas_test "fixup7bug.s" "" "" "check for old \"fixup7\" gas bug"
172
173     # Test an L% selector parsing bug which existed in gas-1.36   
174     do_lsel_test
175
176     # First check how some valid alignments are handled.
177     do_valid_align_tests
178
179     # Now check to make sure an invalid argument is flagged as an error.
180     gas_test_error "align2.s" "" "Check for error on bogus argument to .align"
181
182     gas_test "block1.s" "" "" "Check min/max values for .block"
183
184     # Now check for an invalid argument
185     gas_test_error "block2.s" "" "Check for error on bogus argument to .block"
186
187     # GAS-1.36 choked on this file.
188     # FIXME.  Should check relocations made for this test!
189     gas_test "exprbug.s" "" "" "Check for sym1-sym2 acceptance"
190
191     # Bad things happen in the PA ELF backend (others too?) if a non-default
192     # section is created...
193     setup_xfail "hppa*-*-*elf*" "hppa*-*-linux*" "hppa*64*-*-*"
194     gas_test "ssbug.s" "" "" "Check for acceptance of non-default subspaces"
195
196     # To be compatable with certain "features" of the HP compiler
197     # non-existant registers should default to %r0.
198     gas_test "defbug.s" "" "" "Missing register should default to %%r0"
199
200     # Make sure GAS understands a reasonable set of standard predefined
201     # registers.  eg %rp, %dp, %sp, etc.
202     gas_test "stdreg.s" "" "" "Test standard predefined registers"
203
204     # Make sure GAS will accept a label without a colon.
205     setup_xfail "hppa*-*-linux*"
206     gas_test "labelbug.s" "" "" "Test label without colon"
207
208     # Make sure we grok # line directives.
209     gas_test "appbug.s" "" "" "Test acceptance of #line directives"
210
211     # Make sure we give errors if a floating point format is specified
212     # for an xmpyu instruction (integer multiple)
213     gas_test_error "xmpyubug.s" "" "Check for error on bogus argument to xmpyu"
214
215     # Make sure gas handles various kinds of .reg pseudo-ops
216     gas_test "regpopbug.s" "" "" "Test for bugs in .reg pseudo-op"
217
218     # Check some bugs that have appeared in parsing .callinfo directives
219     gas_test "callinfobug.s" "" "" "Test for bugs in .callinfo directive"
220
221     # Check for bogus registers in single precision fmpyadd/fmpysub
222     # instructions
223     gas_test_error "badfmpyadd.s" "" "Check for error on bad fmpyadd insn"
224
225     # Make sure we grok spaces in directives.
226     gas_test "space.s" "" "" "Test acceptance of spaces in directives"
227 }
228