summaryrefslogtreecommitdiffstats
path: root/binutils-2.25/gas/testsuite/gas/mt/errors.exp
blob: c8a9f68613a3e68d3d05484c801799a971b8cb8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# 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
    }

}