* sim/cris/asm/opterr5.ms, sim/cris/asm/opterr4.ms,
[deliverable/binutils-gdb.git] / sim / testsuite / lib / sim-defs.exp
index 42374e0977209702b11b0db47ad15da5e5ee7515..3cef3942321a83bbabfbdf5b2caa6f2b583db996 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]
 
@@ -154,17 +161,27 @@ proc sim_run { prog sim_opts prog_opts redir options } {
 # as[(mach-list)]: <assembler options>
 # ld[(mach-list)]: <linker options>
 # sim[(mach-list)]: <simulator options>
+# progopts: <arguments to the program being simulated>
 # 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 requested_machs } {
     global subdir srcdir
     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
@@ -181,11 +198,24 @@ proc run_sim_test { name requested_machs } {
     # Clear default options
     set opts(as) ""
     set opts(ld) ""
+    set opts(progopts) ""
     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 {
@@ -209,6 +239,15 @@ proc run_sim_test { name requested_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
        }
@@ -242,6 +281,18 @@ proc run_sim_test { name requested_machs } {
 
        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)
        }
@@ -250,7 +301,7 @@ proc run_sim_test { name requested_machs } {
        if [info exists cpu_option] {
            set as_options "$as_options $cpu_option=$mach"
        }
-       set comp_output [target_assemble $sourcefile ${name}.o "$as_options"]
+       set comp_output [target_assemble $sourcefile ${name}.o "$as_options $global_as_options"]
 
        if ![string match "" $comp_output] {
            verbose -log "$comp_output" 3
@@ -262,7 +313,7 @@ proc run_sim_test { name requested_machs } {
            set opts(ld,$mach) $opts(ld)
        }
 
-       set comp_output [target_link ${name}.o ${name}.x "$opts(ld,$mach)"]
+       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
@@ -281,7 +332,7 @@ proc run_sim_test { name requested_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" "$opts(progopts)" "" "$options"]
        set status [lindex $result 0]
        set output [lindex $result 1]
 
@@ -289,6 +340,7 @@ proc run_sim_test { name requested_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
@@ -304,6 +356,7 @@ proc run_sim_test { name requested_machs } {
            } 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
@@ -331,20 +384,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.024942 seconds and 4 git commands to generate.