mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-10-18 05:12:33 +08:00
sim/testsuite: Support "requires: simoption <--name-of-option>"
Simulator features can be present or not, typically depending on different-valued configure options, like --enable-sim-hardware[=off|=on]. To avoid failures in test-suite-runs when testing such configurations, a new predicate is needed, as neither "target", "progos" nor "mach" fits cleanly. The immediate need was to check for presence of a simulator option, but rather than a specialized "requires-simoption:" predicate I thought I'd handle the general (parametrized) need, so here's a generic predicate machinery and a (first) predicate to use together with it; checking whether a particular option is supported, by looking at "run --help" output. This was inspired by the check_effective_target_ machinery in the gcc test-suite. Multiple "requires: <requirement> <parameter>" form a list of predicates (with parameters), to be used as a conjunction. sim/testsuite: * lib/sim-defs.exp (sim_check_requires_simoption): New function. (run_sim_test): Support "requires: <requirement> <parameter>".
This commit is contained in:

committed by
Hans-Peter Nilsson

parent
46f238477f
commit
81064d7abc
@ -261,6 +261,41 @@ proc sim_run { prog sim_opts prog_opts redir options } {
|
||||
return [list $return_code $output]
|
||||
}
|
||||
|
||||
# Support function for "#requires: simoption <xx>":
|
||||
# Looks in "run --help" output for <xx>, returns 1 iff <xx> is mentioned
|
||||
# there and looks like an option name, otherwise 0.
|
||||
|
||||
proc sim_check_requires_simoption { optname } {
|
||||
global sim_path
|
||||
set testrun "$sim_path --help"
|
||||
verbose -log "Checking for simoption `$optname'" 3
|
||||
remote_spawn host $testrun
|
||||
set result [remote_wait host 240]
|
||||
|
||||
set return_code [lindex $result 0]
|
||||
if { $return_code != 0 } {
|
||||
perror "Can't execute `$testrun' to check for `$optname'"
|
||||
return 0
|
||||
}
|
||||
|
||||
set output [lindex $result 1]
|
||||
# Remove \r as for regular runs.
|
||||
regsub -all -- "\r" $output "" output
|
||||
|
||||
# The option output format for --help for each line where an
|
||||
# option name is mentioned, is assumed to be two space followed
|
||||
# by the option name followed by a space or left square bracket,
|
||||
# like in (optname=--foo): " --foo " or " --foo[this|that]".
|
||||
# Beware not to match " --foo-bar" nor " --foobar".
|
||||
if [string match "*\n $optname\[\[ \]*" $output] {
|
||||
verbose -log "Found `$optname'" 3
|
||||
return 1
|
||||
}
|
||||
verbose -log "Did not find `$optname'" 3
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Run testcase NAME.
|
||||
# NAME is either a fully specified file name, or just the file name in which
|
||||
# case $srcdir/$subdir will be prepended.
|
||||
@ -326,6 +361,7 @@ proc run_sim_test { name requested_machs } {
|
||||
set opts(cc) ""
|
||||
set opts(progopts) ""
|
||||
set opts(progos) ""
|
||||
set opts(requires) {}
|
||||
set opts(sim) ""
|
||||
set opts(status) "0"
|
||||
set opts(output) ""
|
||||
@ -375,6 +411,14 @@ proc run_sim_test { name requested_machs } {
|
||||
set opt_val "$opts($opt_name) $opt_val"
|
||||
}
|
||||
|
||||
# Similar for "requires", except we append a pair to a list, and
|
||||
# that doesn't match the processing in the rest of the loop, so we
|
||||
# "continue" early.
|
||||
if { $opt_name == "requires" } {
|
||||
lappend opts($opt_name) [split $opt_val " "]
|
||||
continue
|
||||
}
|
||||
|
||||
foreach m $opt_machs {
|
||||
set opts($opt_name,$m) $opt_val
|
||||
}
|
||||
@ -449,6 +493,22 @@ proc run_sim_test { name requested_machs } {
|
||||
set opts(cc,$mach) $opts(cc)
|
||||
}
|
||||
|
||||
foreach req $opts(requires) {
|
||||
set what [lindex $req 0]
|
||||
set what_opt [lindex $req 1]
|
||||
verbose -log "requires: <$what> <$what_opt>"
|
||||
if { [info procs sim_check_requires_${what}] != [list] } {
|
||||
if ![sim_check_requires_${what} $what_opt] {
|
||||
untested $subdir/$name
|
||||
return
|
||||
}
|
||||
} {
|
||||
perror "unknown requirement `requires: $what' in file $file"
|
||||
unresolved $subdir/$name
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if [string match "*.c" $sourcefile] {
|
||||
# If we don't have a compiler available, skip tests :(.
|
||||
if { $global_cc_works == 0 } {
|
||||
|
Reference in New Issue
Block a user