1 # Copyright (C) 2005, 2007 Free Software Foundation, Inc.
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.
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.
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.
17 # Miscellaneous CRIS simulator testcases testing syscall sequences.
19 if ![istarget cris*-*-*] {
23 set CFLAGS_FOR_TARGET "-O2"
24 if [istarget cris-*-*] {
30 # Using target_compile, since it is less noisy,
31 if { [target_compile $srcdir/$subdir/hello.c compilercheck.x \
32 "executable" "" ] == "" } {
35 verbose -log "Can't execute C compiler"
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]] {
51 foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
52 if ![runtest_file_p $runtests $src] {
55 set testname "[file tail $src]"
57 set opt_array [slurp_options $src]
58 if { $opt_array == -1 } {
63 # And again, to simplify specifying tests.
64 if ![runtest_file_p $runtests $src] {
68 # Note absence of CC in results, but don't make a big fuss over it.
74 # Clear default options
78 set opts(progoptions) ""
82 set opts(dest) "$testname.x"
89 # Clear any machine specific options specified in a previous test case
90 if [info exists opts(sim,$mach)] {
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"
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
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"
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"
124 foreach m $opt_machs {
125 set opts($opt_name,$m) $opt_val
127 if { "$opt_machs" == "" } {
128 set opts($opt_name) $opt_val
132 if { $opts(output) == "" } {
133 if { "$opts(xerror)" == "no" } {
134 set opts(output) "pass\n"
136 set opts(output) "fail\n"
140 if { $opts(target) != "" && ![anytarget $opts(target)] } {
144 if { $opts(notarget) != "" && [anytarget $opts(notarget)] } {
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)
153 # Change \n sequences to newline chars.
154 regsub -all "\\\\n" $opts(output) "\n" opts(output)
156 verbose -log "Compiling $src with $opts(cc)"
158 set dest "$opts(dest)"
159 if { [sim_compile $src $dest "executable" "$opts(cc)" ] != "" } {
164 verbose -log "Simulating $src with $opts(sim,$mach)"
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
171 eval setup_xfail $opts(xfail)
173 if { "$opts(kfail)" != "" } {
174 verbose -log "kfail: $opts(kfail)"
175 eval setup_kfail $opts(kfail)
178 set result [sim_run $dest "$opts(sim,$mach)" "$opts(progoptions)" \
180 set status [lindex $result 0]
181 set output [lindex $result 1]
183 if { "$status" == "pass" } {
184 if { "$opts(xerror)" == "no" } {
185 if [string match $opts(output) $output] {
186 pass "$mach $testname"
188 verbose -log "output: $output" 3
189 verbose -log "pattern: $opts(output)" 3
190 fail "$mach $testname (execution)"
193 verbose -log "`pass' return code when expecting failure" 3
194 fail "$mach $testname (execution)"
196 } elseif { "$status" == "fail" } {
197 if { "$opts(xerror)" == "no" } {
198 fail "$mach $testname (execution)"
200 if [string match $opts(output) $output] {
201 pass "$mach $testname"
203 verbose -log "output: $output" 3
204 verbose -log "pattern: $opts(output)" 3
205 fail "$mach $testname (execution)"
209 $status "$mach $testname"