]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - sim/testsuite/sim/cris/c/c.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / sim / testsuite / sim / cris / c / c.exp
1 # Copyright (C) 2005, 2007 Free Software Foundation, Inc.
2 #
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
17 # Miscellaneous CRIS simulator testcases testing syscall sequences.
18
19 if ![istarget cris*-*-*] {
20 return
21 }
22
23 set CFLAGS_FOR_TARGET "-O2"
24 if [istarget cris-*-*] {
25 set mach "crisv10"
26 } {
27 set mach "crisv32"
28 }
29
30 # Using target_compile, since it is less noisy,
31 if { [target_compile $srcdir/$subdir/hello.c compilercheck.x \
32 "executable" "" ] == "" } {
33 set has_cc 1
34 } {
35 verbose -log "Can't execute C compiler"
36 set has_cc 0
37 }
38
39 # Like istarget, except take a list of targets as a string.
40 proc anytarget { targets } {
41 set targetlist [split $targets]
42 set argc [llength $targetlist]
43 for { set i 0 } { $i < $argc } { incr i } {
44 if [istarget [lindex $targetlist $i]] {
45 return 1
46 }
47 }
48 return 0
49 }
50
51 foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
52 if ![runtest_file_p $runtests $src] {
53 continue
54 }
55 set testname "[file tail $src]"
56
57 set opt_array [slurp_options $src]
58 if { $opt_array == -1 } {
59 unresolved $testname
60 return
61 }
62
63 # And again, to simplify specifying tests.
64 if ![runtest_file_p $runtests $src] {
65 continue
66 }
67
68 # Note absence of CC in results, but don't make a big fuss over it.
69 if { $has_cc == 0 } {
70 untested $testname
71 continue
72 }
73
74 # Clear default options
75 set opts(cc) ""
76 set opts(sim) ""
77 set opts(output) ""
78 set opts(progoptions) ""
79 set opts(timeout) ""
80 set opts(mach) ""
81 set opts(xerror) "no"
82 set opts(dest) "$testname.x"
83 set opts(simenv) ""
84 set opts(kfail) ""
85 set opts(xfail) ""
86 set opts(target) ""
87 set opts(notarget) ""
88
89 # Clear any machine specific options specified in a previous test case
90 if [info exists opts(sim,$mach)] {
91 unset opts(sim,$mach)
92 }
93
94 foreach i $opt_array {
95 set opt_name [lindex $i 0]
96 set opt_machs [lindex $i 1]
97 set opt_val [lindex $i 2]
98 if ![info exists opts($opt_name)] {
99 perror "unknown option $opt_name in file $src"
100 unresolved $testname
101 return
102 }
103
104 # Replace specific substitutions:
105 # @exedir@ is where the test-program is located.
106 regsub -all "@exedir@" $opt_val "[pwd]" opt_val
107 # @srcdir@ is where the source of the test-program is located.
108 regsub -all "@srcdir@" $opt_val "$srcdir/$subdir" opt_val
109
110 # Multiple of these options concatenate, they don't override.
111 if { $opt_name == "output" || $opt_name == "progoptions" } {
112 set opt_val "$opts($opt_name)$opt_val"
113 }
114
115 # Similar with "xfail", "kfail", "target" and "notarget", but
116 # arguments are space-separated.
117 if { $opt_name == "xfail" || $opt_name == "kfail" \
118 || $opt_name == "target" || $opt_name == "notarget" } {
119 if { $opts($opt_name) != "" } {
120 set opt_val "$opts($opt_name) $opt_val"
121 }
122 }
123
124 foreach m $opt_machs {
125 set opts($opt_name,$m) $opt_val
126 }
127 if { "$opt_machs" == "" } {
128 set opts($opt_name) $opt_val
129 }
130 }
131
132 if { $opts(output) == "" } {
133 if { "$opts(xerror)" == "no" } {
134 set opts(output) "pass\n"
135 } else {
136 set opts(output) "fail\n"
137 }
138 }
139
140 if { $opts(target) != "" && ![anytarget $opts(target)] } {
141 continue
142 }
143
144 if { $opts(notarget) != "" && [anytarget $opts(notarget)] } {
145 continue
146 }
147
148 # If no machine specific options, default to the general version.
149 if ![info exists opts(sim,$mach)] {
150 set opts(sim,$mach) $opts(sim)
151 }
152
153 # Change \n sequences to newline chars.
154 regsub -all "\\\\n" $opts(output) "\n" opts(output)
155
156 verbose -log "Compiling $src with $opts(cc)"
157
158 set dest "$opts(dest)"
159 if { [sim_compile $src $dest "executable" "$opts(cc)" ] != "" } {
160 unresolved $testname
161 continue
162 }
163
164 verbose -log "Simulating $src with $opts(sim,$mach)"
165
166 # Time to setup xfailures and kfailures.
167 if { "$opts(xfail)" != "" } {
168 verbose -log "xfail: $opts(xfail)"
169 # Using eval to make $opts(xfail) appear as individual
170 # arguments.
171 eval setup_xfail $opts(xfail)
172 }
173 if { "$opts(kfail)" != "" } {
174 verbose -log "kfail: $opts(kfail)"
175 eval setup_kfail $opts(kfail)
176 }
177
178 set result [sim_run $dest "$opts(sim,$mach)" "$opts(progoptions)" \
179 "" "$opts(simenv)"]
180 set status [lindex $result 0]
181 set output [lindex $result 1]
182
183 if { "$status" == "pass" } {
184 if { "$opts(xerror)" == "no" } {
185 if [string match $opts(output) $output] {
186 pass "$mach $testname"
187 } else {
188 verbose -log "output: $output" 3
189 verbose -log "pattern: $opts(output)" 3
190 fail "$mach $testname (execution)"
191 }
192 } else {
193 verbose -log "`pass' return code when expecting failure" 3
194 fail "$mach $testname (execution)"
195 }
196 } elseif { "$status" == "fail" } {
197 if { "$opts(xerror)" == "no" } {
198 fail "$mach $testname (execution)"
199 } else {
200 if [string match $opts(output) $output] {
201 pass "$mach $testname"
202 } else {
203 verbose -log "output: $output" 3
204 verbose -log "pattern: $opts(output)" 3
205 fail "$mach $testname (execution)"
206 }
207 }
208 } else {
209 $status "$mach $testname"
210 }
211 }