* arm-opc.h (arm_opcode, thumb_opcode): Add extra field for the
[deliverable/binutils-gdb.git] / sim / testsuite / lib / sim-defs.exp
index 16a742fb6da99455a316a7af63baf13f1632ec18..521e0e33a2d76ba61045e649a65fde64c9e36c65 100644 (file)
@@ -93,7 +93,7 @@ proc sim_run { prog sim_opts prog_opts redir options } {
        set prog [remote_download host $prog]
        if { $prog == "" } {
            error "download failed"
-           return -1;
+           return -1
        }
     }
 
@@ -109,12 +109,19 @@ proc sim_run { prog sim_opts prog_opts redir options } {
        set sim "env $testcase_env $sim"
     }
 
-    send_log "$sim $always_opts $SIMFLAGS $sim_opts $prog $prog_opts\n"
+    if { [board_info target sim,protocol] == "sid" } {
+       set cmd ""
+       set sim_opts "$sim_opts -e \"set cpu-loader file [list ${prog}]\""
+    } else {
+       set cmd "$prog"
+    }
+
+    send_log "$sim $always_opts $SIMFLAGS $sim_opts $cmd $prog_opts\n"
 
     if { "$redir" == "" } {
-       remote_spawn host "$sim $always_opts $SIMFLAGS $sim_opts $prog $prog_opts"
+       remote_spawn host "$sim $always_opts $SIMFLAGS $sim_opts $cmd $prog_opts"
     } else {
-       remote_spawn host "$sim $always_opts $SIMFLAGS $sim_opts $prog $prog_opts $redir" writeonly
+       remote_spawn host "$sim $always_opts $SIMFLAGS $sim_opts $cmd $prog_opts $redir" writeonly
     }
     set result [remote_wait host $testcase_timeout]
 
@@ -143,23 +150,37 @@ proc sim_run { prog sim_opts prog_opts redir options } {
 # Run testcase NAME.
 # NAME is either a fully specified file name, or just the file name in which
 # case $srcdir/$subdir will be prepended.
-# ALL_MACHS is a list of machs to use if "mach: all" is specified in the file.
-# The file can contain options in the form "# option(mach list): value"
+# REQUESTED_MACHS is a list of machines to run the testcase on.  If NAME isn't
+# for the specified machine(s), it is ignored.
+# Typically REQUESTED_MACHS contains just one element, it is up to the caller
+# to iterate over the desired machine variants.
+#
+# The file can contain options in the form "# option(mach list): value".
 # Possibilities:
 # mach: [all | machine names]
 # as[(mach-list)]: <assembler options>
 # ld[(mach-list)]: <linker options>
 # sim[(mach-list)]: <simulator options>
-# output[(mach-list)]: program output pattern to match with string-match
-# xerror[(mach-list)]: program is expected to return with a "failure" exit code
+# output: program output pattern to match with string-match
+# xerror: program is expected to return with a "failure" exit code
+# xfail: <PRMS-opt> <target-triplets-where-test-fails>
+# kfail: <PRMS> <target-triplets-where-test-fails>
 # If `output' is not specified, the program must output "pass" if !xerror or
 # "fail" if xerror.
 # The parens in "optname()" are optional if the specification is for all machs.
+# Multiple "output", "xfail" and "kfail" options concatenate.
+# The xfail and kfail arguments are space-separated target triplets and PRIDs.
+# There must be a PRMS (bug report ID) specified for kfail, while it's
+# optional for xfail.
 
-proc run_sim_test { name all_machs } {
+proc run_sim_test { name requested_machs } {
     global subdir srcdir
-    global AS ASFLAGS LD LDFLAGS SIMFLAGS
+    global SIMFLAGS
     global opts
+    global cpu_option
+    global global_as_options
+    global global_ld_options
+    global global_sim_options
 
     if [string match "*/*" $name] {
        set file $name
@@ -173,13 +194,39 @@ proc run_sim_test { name all_machs } {
        unresolved $subdir/$name
        return
     }
-    set opts(as) {}
-    set opts(ld) {}
-    set opts(sim) {}
-    set opts(output) {}
-    set opts(mach) {}
-    set opts(timeout) {}
+    # Clear default options
+    set opts(as) ""
+    set opts(ld) ""
+    set opts(sim) ""
+    set opts(output) ""
+    set opts(mach) ""
+    set opts(timeout) ""
     set opts(xerror) "no"
+    set opts(xfail) ""
+    set opts(kfail) ""
+
+    if ![info exists global_as_options] {
+        set global_as_options ""
+    }
+    if ![info exists global_ld_options] {
+        set global_ld_options ""
+    }
+    if ![info exists global_sim_options] {
+        set global_sim_options ""
+    }
+
+    # Clear any machine specific options specified in a previous test case
+    foreach m $requested_machs {
+       if [info exists opts(as,$m)] {
+           unset opts(as,$m)
+       }
+       if [info exists opts(ld,$m)] {
+           unset opts(ld,$m)
+       }
+       if [info exists opts(sim,$m)] {
+           unset opts(sim,$m)
+       }
+    }
 
     foreach i $opt_array {
        set opt_name [lindex $i 0]
@@ -190,6 +237,15 @@ proc run_sim_test { name all_machs } {
            unresolved $subdir/$name
            return
        }
+       # Multiple "output" specifications concatenate, they don't override.
+       if { $opt_name == "output" } {
+           set opt_val "$opts(output)$opt_val"
+       }
+       # Similar with "xfail" and "kfail", but arguments are space-separated.
+       if { $opt_name == "xfail" || $opt_name == "kfail" } {
+           set opt_val "$opts($opt_name) $opt_val"
+       }
+
        foreach m $opt_machs {
            set opts($opt_name,$m) $opt_val
        }
@@ -210,30 +266,56 @@ proc run_sim_test { name all_machs } {
     # Change \n sequences to newline chars.
     regsub -all "\\\\n" $opts(output) "\n" opts(output)
 
-    foreach mach $opts(mach) {
-       verbose "Testing $name on $mach."
+    set testcase_machs $opts(mach)
+    if { "$testcase_machs" == "all" } {
+       set testcase_machs $requested_machs
+    }
+
+    foreach mach $testcase_machs {
+       if { [lsearch $requested_machs $mach] < 0 } {
+           verbose -log "Skipping $mach version of $name, not requested."
+           continue
+       }
+
+       verbose -log "Testing $name on machine $mach."
+
+       # Time to setup xfailures and kfailures.
+       if { "$opts(xfail)" != "" } {
+           verbose -log "xfail: $opts(xfail)"
+           # Using eval to make $opts(xfail) appear as individual
+           # arguments.
+           eval setup_xfail $opts(xfail)
+       }
+       if { "$opts(kfail)" != "" } {
+           verbose -log "kfail: $opts(kfail)"
+           eval setup_kfail $opts(kfail)
+       }
 
        if ![info exists opts(as,$mach)] {
            set opts(as,$mach) $opts(as)
        }
-       send_log "$AS $ASFLAGS $opts(as,$mach) -I$srcdir/$subdir -o ${name}.o $sourcefile\n"
-       catch "exec $AS $ASFLAGS $opts(as,$mach) -I$srcdir/$subdir -o ${name}.o $sourcefile" comp_output
+
+       set as_options "$opts(as,$mach) -I$srcdir/$subdir"
+       if [info exists cpu_option] {
+           set as_options "$as_options $cpu_option=$mach"
+       }
+       set comp_output [target_assemble $sourcefile ${name}.o "$as_options $global_as_options"]
 
        if ![string match "" $comp_output] {
            verbose -log "$comp_output" 3
-           fail "$mach $testname"
+           fail "$mach $testname (assembling)"
            continue
        }
 
        if ![info exists opts(ld,$mach)] {
            set opts(ld,$mach) $opts(ld)
        }
-       send_log "$LD $LDFLAGS $opts(ld,$mach) -o ${name}.x ${name}.o\n"
-       catch "exec $LD $LDFLAGS $opts(ld,$mach) -o ${name}.x ${name}.o" comp_output
+
+       set comp_output [target_link ${name}.o ${name}.x "$opts(ld,$mach) $global_ld_options"]
 
        if ![string match "" $comp_output] {
            verbose -log "$comp_output" 3
-           fail "$mach $testname"
+           fail "$mach $testname (linking)"
            continue
        }
 
@@ -248,7 +330,7 @@ proc run_sim_test { name all_machs } {
            set options "$options timeout=$opts(timeout)"
        }
 
-       set result [sim_run ${name}.x "$opts(sim,$mach)" "" "" "$options"]
+       set result [sim_run ${name}.x "$opts(sim,$mach) $global_sim_options" "" "" "$options"]
        set status [lindex $result 0]
        set output [lindex $result 1]
 
@@ -256,25 +338,27 @@ proc run_sim_test { name all_machs } {
            if { "$opts(xerror)" == "no" } {
                if [string match $opts(output) $output] {
                    pass "$mach $testname"
+                   file delete ${name}.o ${name}.x
                } else {
                    verbose -log "output:  $output" 3
                    verbose -log "pattern: $opts(output)" 3
-                   fail "$mach $testname"
+                   fail "$mach $testname (execution)"
                }
            } else {
                verbose -log "`pass' return code when expecting failure" 3
-               fail "$mach $testname"
+               fail "$mach $testname (execution)"
            }
        } elseif { "$status" == "fail" } {
            if { "$opts(xerror)" == "no" } {
-               fail "$mach $testname"
+               fail "$mach $testname (execution)"
            } else {
                if [string match $opts(output) $output] {
                    pass "$mach $testname"
+                   file delete ${name}.o ${name}.x
                } else {
                    verbose -log "output:  $output" 3
                    verbose -log "pattern: $opts(output)" 3
-                   fail "$mach $testname"
+                   fail "$mach $testname (execution)"
                }
            }
        } else {
@@ -298,20 +382,20 @@ proc slurp_options { file } {
     # whitespace is ignored anywhere except within the options list;
     # option names are alphabetic only
     set pat "^#${ws}(\[a-zA-Z\]*)\\(?(\[^):\]*)\\)?$ws:${ws}(.*)$ws\$"
-    # Allow comment as first line of file.
-    set firstline 1
+    # Allow arbitrary lines until the first option is seen.
+    set seen_opt 0
     while { [gets $f line] != -1 } {
        set line [string trim $line]
        # Whitespace here is space-tab.
        if [regexp $pat $line xxx opt_name opt_machs opt_val] {
            # match!
            lappend opt_array [list $opt_name $opt_machs $opt_val]
+           set seen_opt 1
        } else {
-           if { ! $firstline } {
+           if { $seen_opt } {
                break
            }
        }
-       set firstline 0
     }
     close $f
     return $opt_array
This page took 0.026173 seconds and 4 git commands to generate.