| # Copyright 2012 |
| # Free Software Foundation, Inc. |
| |
| # 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 3 of the License, 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, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. |
| |
| # Test for error messages when a bad register name, an out of range operand, or |
| # invalid syntax is used. Adapted from Ben Elliston's load-hazard testcase. |
| |
| # Run GAS and check that it emits the desired error for the test case. |
| # Arguments: |
| # file -- name of the test case to assemble. |
| # testname -- a string describing the test. |
| # warnpattern -- a regular expression, suitable for use by the Tcl |
| # regexp command, to decide if the warning string was emitted by |
| # the assembler to stderr. |
| |
| proc mrisc1_error_test { file testname {warnpattern ""} } { |
| global comp_output |
| |
| gas_run $file "" ">/dev/null" |
| verbose "output was $comp_output" 2 |
| |
| if {$warnpattern == ""} { |
| if {$comp_output == ""} { pass $testname } else { fail $testname } |
| return |
| } |
| |
| if {[regexp "Error: $warnpattern" $comp_output]} { |
| pass $testname |
| } else { |
| fail $testname |
| } |
| } |
| |
| if [istarget mt-*-*] { |
| foreach file [lsort [glob -nocomplain -- $srcdir/$subdir/bad*.s]] { |
| set file [file tail $file] |
| switch -- $file { |
| "badreg.s" { |
| set warnpattern "unrecognized keyword/register name *" |
| } |
| "badorder.s" { |
| set warnpattern "unrecognized form of instruction*" |
| } |
| "badsyntax.s" { |
| set warnpattern "unrecognized keyword/register name *" |
| } |
| "badsyntax1.s" { |
| set warnpattern "unrecognized form of instruction*" |
| } |
| "badoffsethigh.s" { |
| set warnpattern "Operand out of range. Must be between -32768 and 32767.*" |
| } |
| "badoffsetlow.s" { |
| set warnpattern "Operand out of range. Must be between -32768 and 32767.*" |
| } |
| "badunsignedimmhigh.s" { |
| set warnpattern "operand out of range (65536 not between 0 and 65535)*" |
| } |
| "badunsignedimmlow.s" { |
| set warnpattern "operand out of range (65536 not between 0 and 65535)*" |
| } |
| "badsignedimmhigh.s" { |
| set warnpattern "operand out of range.*" |
| } |
| "badsignedimmlow.s" { |
| set warnpattern "operand out of range.*" |
| } |
| "badinsn.s" { |
| set warnpattern "unrecognized instruction *" |
| } |
| "badinsn1.s" { |
| set warnpattern "junk at end of line *" |
| } |
| default { |
| error "no expected result specified for $file" |
| return |
| |
| } |
| } |
| mrisc1_error_test $file "assembler emits error for $file" $warnpattern |
| } |
| |
| } |