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