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