]>
Commit | Line | Data |
---|---|---|
5bf135a7 NC |
1 | # Copyright 2012 |
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 | ||
a0defb2e AH |
18 | # Test for error messages when a bad register name, an out of range operand, or |
19 | # invalid syntax is used. Adapted from Ben Elliston's load-hazard testcase. | |
20 | ||
21 | # Run GAS and check that it emits the desired error for the test case. | |
22 | # Arguments: | |
23 | # file -- name of the test case to assemble. | |
24 | # testname -- a string describing the test. | |
25 | # warnpattern -- a regular expression, suitable for use by the Tcl | |
26 | # regexp command, to decide if the warning string was emitted by | |
27 | # the assembler to stderr. | |
28 | ||
29 | proc mrisc1_error_test { file testname {warnpattern ""} } { | |
30 | global comp_output | |
31 | ||
32 | gas_run $file "" ">/dev/null" | |
33 | verbose "output was $comp_output" 2 | |
34 | ||
35 | if {$warnpattern == ""} { | |
36 | if {$comp_output == ""} { pass $testname } else { fail $testname } | |
37 | return | |
38 | } | |
39 | ||
40 | if {[regexp "Error: $warnpattern" $comp_output]} { | |
41 | pass $testname | |
42 | } else { | |
43 | fail $testname | |
44 | } | |
45 | } | |
46 | ||
4970f871 | 47 | if [istarget mt-*-*] { |
4287f8de | 48 | foreach file [lsort [glob -nocomplain -- $srcdir/$subdir/bad*.s]] { |
a0defb2e AH |
49 | set file [file tail $file] |
50 | switch -- $file { | |
51 | "badreg.s" { | |
52 | set warnpattern "unrecognized keyword/register name *" | |
53 | } | |
54 | "badorder.s" { | |
55 | set warnpattern "unrecognized form of instruction*" | |
56 | } | |
57 | "badsyntax.s" { | |
58 | set warnpattern "unrecognized keyword/register name *" | |
59 | } | |
60 | "badsyntax1.s" { | |
61 | set warnpattern "unrecognized form of instruction*" | |
62 | } | |
63 | "badoffsethigh.s" { | |
64 | set warnpattern "Operand out of range. Must be between -32768 and 32767.*" | |
65 | } | |
66 | "badoffsetlow.s" { | |
67 | set warnpattern "Operand out of range. Must be between -32768 and 32767.*" | |
68 | } | |
69 | "badunsignedimmhigh.s" { | |
70 | set warnpattern "operand out of range (65536 not between 0 and 65535)*" | |
71 | } | |
72 | "badunsignedimmlow.s" { | |
73 | set warnpattern "operand out of range (65536 not between 0 and 65535)*" | |
74 | } | |
75 | "badsignedimmhigh.s" { | |
76 | set warnpattern "operand out of range.*" | |
77 | } | |
78 | "badsignedimmlow.s" { | |
79 | set warnpattern "operand out of range.*" | |
80 | } | |
81 | "badinsn.s" { | |
82 | set warnpattern "unrecognized instruction *" | |
83 | } | |
84 | "badinsn1.s" { | |
85 | set warnpattern "junk at end of line *" | |
86 | } | |
87 | default { | |
88 | error "no expected result specified for $file" | |
89 | return | |
90 | ||
91 | } | |
92 | } | |
93 | mrisc1_error_test $file "assembler emits error for $file" $warnpattern | |
94 | } | |
95 | ||
96 | } |