1 # Copyright (C) 2005, 2007, 2008 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 3 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, see <http://www.gnu.org/licenses/>.
16 # Miscellaneous CRIS simulator testcases testing syscall sequences.
18 if ![istarget cris*-*-*] {
22 set CFLAGS_FOR_TARGET "-O2"
23 if [istarget cris-*-*] {
29 # Using target_compile, since it is less noisy,
30 if { [target_compile $srcdir/$subdir/hello.c compilercheck.x \
31 "executable" "" ] == "" } {
34 verbose -log "Can't execute C compiler"
38 # Like istarget, except take a list of targets as a string.
39 proc anytarget { targets } {
40 set targetlist [split $targets]
41 set argc [llength $targetlist]
42 for { set i 0 } { $i < $argc } { incr i } {
43 if [istarget [lindex $targetlist $i]] {
50 foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
51 if ![runtest_file_p $runtests $src] {
54 set testname "[file tail $src]"
56 set opt_array [slurp_options $src]
57 if { $opt_array == -1 } {
62 # And again, to simplify specifying tests.
63 if ![runtest_file_p $runtests $src] {
67 # Note absence of CC in results, but don't make a big fuss over it.
73 # Clear default options
77 set opts(progoptions) ""
81 set opts(dest) "$testname.x"
88 # Clear any machine specific options specified in a previous test case
89 if [info exists opts(sim,$mach)] {
93 foreach i $opt_array {
94 set opt_name [lindex $i 0]
95 set opt_machs [lindex $i 1]
96 set opt_val [lindex $i 2]
97 if ![info exists opts($opt_name)] {
98 perror "unknown option $opt_name in file $src"
103 # Replace specific substitutions:
104 # @exedir@ is where the test-program is located.
105 regsub -all "@exedir@" $opt_val "[pwd]" opt_val
106 # @srcdir@ is where the source of the test-program is located.
107 regsub -all "@srcdir@" $opt_val "$srcdir/$subdir" opt_val
109 # Multiple of these options concatenate, they don't override.
110 if { $opt_name == "output" || $opt_name == "progoptions" } {
111 set opt_val "$opts($opt_name)$opt_val"
114 # Similar with "xfail", "kfail", "target" and "notarget", but
115 # arguments are space-separated.
116 if { $opt_name == "xfail" || $opt_name == "kfail" \
117 || $opt_name == "target" || $opt_name == "notarget" } {
118 if { $opts($opt_name) != "" } {
119 set opt_val "$opts($opt_name) $opt_val"
123 foreach m $opt_machs {
124 set opts($opt_name,$m) $opt_val
126 if { "$opt_machs" == "" } {
127 set opts($opt_name) $opt_val
131 if { $opts(output) == "" } {
132 if { "$opts(xerror)" == "no" } {
133 set opts(output) "pass\n"
135 set opts(output) "fail\n"
139 if { $opts(target) != "" && ![anytarget $opts(target)] } {
143 if { $opts(notarget) != "" && [anytarget $opts(notarget)] } {
147 # If no machine specific options, default to the general version.
148 if ![info exists opts(sim,$mach)] {
149 set opts(sim,$mach) $opts(sim)
152 # Change \n sequences to newline chars.
153 regsub -all "\\\\n" $opts(output) "\n" opts(output)
155 verbose -log "Compiling $src with $opts(cc)"
157 set dest "$opts(dest)"
158 if { [sim_compile $src $dest "executable" "$opts(cc)" ] != "" } {
163 verbose -log "Simulating $src with $opts(sim,$mach)"
165 # Time to setup xfailures and kfailures.
166 if { "$opts(xfail)" != "" } {
167 verbose -log "xfail: $opts(xfail)"
168 # Using eval to make $opts(xfail) appear as individual
170 eval setup_xfail $opts(xfail)
172 if { "$opts(kfail)" != "" } {
173 verbose -log "kfail: $opts(kfail)"
174 eval setup_kfail $opts(kfail)
177 set result [sim_run $dest "$opts(sim,$mach)" "$opts(progoptions)" \
179 set status [lindex $result 0]
180 set output [lindex $result 1]
182 if { "$status" == "pass" } {
183 if { "$opts(xerror)" == "no" } {
184 if [string match $opts(output) $output] {
185 pass "$mach $testname"
187 verbose -log "output: $output" 3
188 verbose -log "pattern: $opts(output)" 3
189 fail "$mach $testname (execution)"
192 verbose -log "`pass' return code when expecting failure" 3
193 fail "$mach $testname (execution)"
195 } elseif { "$status" == "fail" } {
196 if { "$opts(xerror)" == "no" } {
197 fail "$mach $testname (execution)"
199 if [string match $opts(output) $output] {
200 pass "$mach $testname"
202 verbose -log "output: $output" 3
203 verbose -log "pattern: $opts(output)" 3
204 fail "$mach $testname (execution)"
208 $status "$mach $testname"