# Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc.
|
# Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc.
|
#
|
#
|
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
# the Free Software Foundation; either version 3 of the License, or
|
# the Free Software Foundation; either version 3 of the License, or
|
# (at your option) any later version.
|
# (at your option) any later version.
|
#
|
#
|
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
#
|
#
|
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
# along with this program. If not, see .
|
# along with this program. If not, see .
|
|
|
# Miscellaneous CRIS simulator testcases testing syscall sequences.
|
# Miscellaneous CRIS simulator testcases testing syscall sequences.
|
|
|
if ![istarget cris*-*-*] {
|
if ![istarget cris*-*-*] {
|
return
|
return
|
}
|
}
|
|
|
set CFLAGS_FOR_TARGET "-O2"
|
set CFLAGS_FOR_TARGET "-O2"
|
if [istarget cris-*-*] {
|
if [istarget cris-*-*] {
|
set mach "crisv10"
|
set mach "crisv10"
|
} {
|
} {
|
set mach "crisv32"
|
set mach "crisv32"
|
}
|
}
|
|
|
# Using target_compile, since it is less noisy,
|
# Using target_compile, since it is less noisy,
|
if { [target_compile $srcdir/$subdir/hello.c compilercheck.x \
|
if { [target_compile $srcdir/$subdir/hello.c compilercheck.x \
|
"executable" "" ] == "" } {
|
"executable" "" ] == "" } {
|
set has_cc 1
|
set has_cc 1
|
} {
|
} {
|
verbose -log "Can't execute C compiler"
|
verbose -log "Can't execute C compiler"
|
set has_cc 0
|
set has_cc 0
|
}
|
}
|
|
|
# Like istarget, except take a list of targets as a string.
|
# Like istarget, except take a list of targets as a string.
|
proc anytarget { targets } {
|
proc anytarget { targets } {
|
set targetlist [split $targets]
|
set targetlist [split $targets]
|
set argc [llength $targetlist]
|
set argc [llength $targetlist]
|
for { set i 0 } { $i < $argc } { incr i } {
|
for { set i 0 } { $i < $argc } { incr i } {
|
if [istarget [lindex $targetlist $i]] {
|
if [istarget [lindex $targetlist $i]] {
|
return 1
|
return 1
|
}
|
}
|
}
|
}
|
return 0
|
return 0
|
}
|
}
|
|
|
foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
|
foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
|
if ![runtest_file_p $runtests $src] {
|
if ![runtest_file_p $runtests $src] {
|
continue
|
continue
|
}
|
}
|
set testname "[file tail $src]"
|
set testname "[file tail $src]"
|
|
|
set opt_array [slurp_options $src]
|
set opt_array [slurp_options $src]
|
if { $opt_array == -1 } {
|
if { $opt_array == -1 } {
|
unresolved $testname
|
unresolved $testname
|
return
|
return
|
}
|
}
|
|
|
# And again, to simplify specifying tests.
|
# And again, to simplify specifying tests.
|
if ![runtest_file_p $runtests $src] {
|
if ![runtest_file_p $runtests $src] {
|
continue
|
continue
|
}
|
}
|
|
|
# Note absence of CC in results, but don't make a big fuss over it.
|
# Note absence of CC in results, but don't make a big fuss over it.
|
if { $has_cc == 0 } {
|
if { $has_cc == 0 } {
|
untested $testname
|
untested $testname
|
continue
|
continue
|
}
|
}
|
|
|
# Clear default options
|
# Clear default options
|
set opts(cc) ""
|
set opts(cc) ""
|
set opts(sim) ""
|
set opts(sim) ""
|
set opts(output) ""
|
set opts(output) ""
|
set opts(progoptions) ""
|
set opts(progoptions) ""
|
set opts(timeout) ""
|
set opts(timeout) ""
|
set opts(mach) ""
|
set opts(mach) ""
|
set opts(xerror) "no"
|
set opts(xerror) "no"
|
set opts(dest) "$testname.x"
|
set opts(dest) "$testname.x"
|
set opts(simenv) ""
|
set opts(simenv) ""
|
set opts(kfail) ""
|
set opts(kfail) ""
|
set opts(xfail) ""
|
set opts(xfail) ""
|
set opts(target) ""
|
set opts(target) ""
|
set opts(notarget) ""
|
set opts(notarget) ""
|
|
|
# Clear any machine specific options specified in a previous test case
|
# Clear any machine specific options specified in a previous test case
|
if [info exists opts(sim,$mach)] {
|
if [info exists opts(sim,$mach)] {
|
unset opts(sim,$mach)
|
unset opts(sim,$mach)
|
}
|
}
|
|
|
foreach i $opt_array {
|
foreach i $opt_array {
|
set opt_name [lindex $i 0]
|
set opt_name [lindex $i 0]
|
set opt_machs [lindex $i 1]
|
set opt_machs [lindex $i 1]
|
set opt_val [lindex $i 2]
|
set opt_val [lindex $i 2]
|
if ![info exists opts($opt_name)] {
|
if ![info exists opts($opt_name)] {
|
perror "unknown option $opt_name in file $src"
|
perror "unknown option $opt_name in file $src"
|
unresolved $testname
|
unresolved $testname
|
return
|
return
|
}
|
}
|
|
|
# Replace specific substitutions:
|
# Replace specific substitutions:
|
# @exedir@ is where the test-program is located.
|
# @exedir@ is where the test-program is located.
|
regsub -all "@exedir@" $opt_val "[pwd]" opt_val
|
regsub -all "@exedir@" $opt_val "[pwd]" opt_val
|
# @srcdir@ is where the source of the test-program is located.
|
# @srcdir@ is where the source of the test-program is located.
|
regsub -all "@srcdir@" $opt_val "$srcdir/$subdir" opt_val
|
regsub -all "@srcdir@" $opt_val "$srcdir/$subdir" opt_val
|
|
|
# Multiple of these options concatenate, they don't override.
|
# Multiple of these options concatenate, they don't override.
|
if { $opt_name == "output" || $opt_name == "progoptions" } {
|
if { $opt_name == "output" || $opt_name == "progoptions" } {
|
set opt_val "$opts($opt_name)$opt_val"
|
set opt_val "$opts($opt_name)$opt_val"
|
}
|
}
|
|
|
# Similar with "xfail", "kfail", "target" and "notarget", but
|
# Similar with "xfail", "kfail", "target" and "notarget", but
|
# arguments are space-separated.
|
# arguments are space-separated.
|
if { $opt_name == "xfail" || $opt_name == "kfail" \
|
if { $opt_name == "xfail" || $opt_name == "kfail" \
|
|| $opt_name == "target" || $opt_name == "notarget" } {
|
|| $opt_name == "target" || $opt_name == "notarget" } {
|
if { $opts($opt_name) != "" } {
|
if { $opts($opt_name) != "" } {
|
set opt_val "$opts($opt_name) $opt_val"
|
set opt_val "$opts($opt_name) $opt_val"
|
}
|
}
|
}
|
}
|
|
|
foreach m $opt_machs {
|
foreach m $opt_machs {
|
set opts($opt_name,$m) $opt_val
|
set opts($opt_name,$m) $opt_val
|
}
|
}
|
if { "$opt_machs" == "" } {
|
if { "$opt_machs" == "" } {
|
set opts($opt_name) $opt_val
|
set opts($opt_name) $opt_val
|
}
|
}
|
}
|
}
|
|
|
if { $opts(output) == "" } {
|
if { $opts(output) == "" } {
|
if { "$opts(xerror)" == "no" } {
|
if { "$opts(xerror)" == "no" } {
|
set opts(output) "pass\n"
|
set opts(output) "pass\n"
|
} else {
|
} else {
|
set opts(output) "fail\n"
|
set opts(output) "fail\n"
|
}
|
}
|
}
|
}
|
|
|
if { $opts(target) != "" && ![anytarget $opts(target)] } {
|
if { $opts(target) != "" && ![anytarget $opts(target)] } {
|
continue
|
continue
|
}
|
}
|
|
|
if { $opts(notarget) != "" && [anytarget $opts(notarget)] } {
|
if { $opts(notarget) != "" && [anytarget $opts(notarget)] } {
|
continue
|
continue
|
}
|
}
|
|
|
# If no machine specific options, default to the general version.
|
# If no machine specific options, default to the general version.
|
if ![info exists opts(sim,$mach)] {
|
if ![info exists opts(sim,$mach)] {
|
set opts(sim,$mach) $opts(sim)
|
set opts(sim,$mach) $opts(sim)
|
}
|
}
|
|
|
# Change \n sequences to newline chars.
|
# Change \n sequences to newline chars.
|
regsub -all "\\\\n" $opts(output) "\n" opts(output)
|
regsub -all "\\\\n" $opts(output) "\n" opts(output)
|
|
|
verbose -log "Compiling $src with $opts(cc)"
|
verbose -log "Compiling $src with $opts(cc)"
|
|
|
set dest "$opts(dest)"
|
set dest "$opts(dest)"
|
if { [sim_compile $src $dest "executable" "$opts(cc)" ] != "" } {
|
if { [sim_compile $src $dest "executable" "$opts(cc)" ] != "" } {
|
unresolved $testname
|
unresolved $testname
|
continue
|
continue
|
}
|
}
|
|
|
verbose -log "Simulating $src with $opts(sim,$mach)"
|
verbose -log "Simulating $src with $opts(sim,$mach)"
|
|
|
# Time to setup xfailures and kfailures.
|
# Time to setup xfailures and kfailures.
|
if { "$opts(xfail)" != "" } {
|
if { "$opts(xfail)" != "" } {
|
verbose -log "xfail: $opts(xfail)"
|
verbose -log "xfail: $opts(xfail)"
|
# Using eval to make $opts(xfail) appear as individual
|
# Using eval to make $opts(xfail) appear as individual
|
# arguments.
|
# arguments.
|
eval setup_xfail $opts(xfail)
|
eval setup_xfail $opts(xfail)
|
}
|
}
|
if { "$opts(kfail)" != "" } {
|
if { "$opts(kfail)" != "" } {
|
verbose -log "kfail: $opts(kfail)"
|
verbose -log "kfail: $opts(kfail)"
|
eval setup_kfail $opts(kfail)
|
eval setup_kfail $opts(kfail)
|
}
|
}
|
|
|
set result [sim_run $dest "$opts(sim,$mach)" "$opts(progoptions)" \
|
set result [sim_run $dest "$opts(sim,$mach)" "$opts(progoptions)" \
|
"" "$opts(simenv)"]
|
"" "$opts(simenv)"]
|
set status [lindex $result 0]
|
set status [lindex $result 0]
|
set output [lindex $result 1]
|
set output [lindex $result 1]
|
|
|
if { "$status" == "pass" } {
|
if { "$status" == "pass" } {
|
if { "$opts(xerror)" == "no" } {
|
if { "$opts(xerror)" == "no" } {
|
if [string match $opts(output) $output] {
|
if [string match $opts(output) $output] {
|
pass "$mach $testname"
|
pass "$mach $testname"
|
} else {
|
} else {
|
verbose -log "output: $output" 3
|
verbose -log "output: $output" 3
|
verbose -log "pattern: $opts(output)" 3
|
verbose -log "pattern: $opts(output)" 3
|
fail "$mach $testname (execution)"
|
fail "$mach $testname (execution)"
|
}
|
}
|
} else {
|
} else {
|
verbose -log "`pass' return code when expecting failure" 3
|
verbose -log "`pass' return code when expecting failure" 3
|
fail "$mach $testname (execution)"
|
fail "$mach $testname (execution)"
|
}
|
}
|
} elseif { "$status" == "fail" } {
|
} elseif { "$status" == "fail" } {
|
if { "$opts(xerror)" == "no" } {
|
if { "$opts(xerror)" == "no" } {
|
fail "$mach $testname (execution)"
|
fail "$mach $testname (execution)"
|
} else {
|
} else {
|
if [string match $opts(output) $output] {
|
if [string match $opts(output) $output] {
|
pass "$mach $testname"
|
pass "$mach $testname"
|
} else {
|
} else {
|
verbose -log "output: $output" 3
|
verbose -log "output: $output" 3
|
verbose -log "pattern: $opts(output)" 3
|
verbose -log "pattern: $opts(output)" 3
|
fail "$mach $testname (execution)"
|
fail "$mach $testname (execution)"
|
}
|
}
|
}
|
}
|
} else {
|
} else {
|
$status "$mach $testname"
|
$status "$mach $testname"
|
}
|
}
|
}
|
}
|
|
|