1 # Copyright
(C
) 1992-2016 Free Software Foundation
, Inc.
3 # This file is part of DejaGnu.
5 # DejaGnu is free software
; you can redistribute it and
/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation
; either version
3 of the License
, or
8 #
(at your option
) any later version.
10 # DejaGnu is distributed in the hope that it will be useful
, but
11 # WITHOUT
ANY WARRANTY
; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License
for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with DejaGnu
; if not
, write to the Free Software Foundation
,
17 # Inc.
, 51 Franklin Street
- Fifth Floor
, Boston
, MA
02110-1301, USA.
20 # sim_load
-- load the
program and
execute it
22 # See default.exp
for explanation of arguments and results.
25 proc sim_spawn
{ dest cmdline
args } {
26 if {![board_info $dest
exists sim
]} {
27 perror
"no simulator defined for [board_info $dest name]"
30 set sim
[board_info $dest sim
]
33 if {[board_info $dest
exists sim
,options
]} {
34 set simflags
[board_info $dest sim
,options
]
39 if {![isremote host
]} {
40 if { [which $sim
] == 0 } {
41 verbose
-log "Simulator $sim missing." 3
46 if {[isremote host
]} {
47 # download the
program to remote.
48 # we
're assuming the program is the first word in the command.
49 # FIXME: "prog < infile" won't work until we download
infile.
50 set prog
[lindex $cmdline
0]
51 set prog
[remote_download host $prog a.out
]
52 set cmdline
[lreplace $cmdline
0 0 $prog
]
55 return [eval remote_spawn host \
{ $sim $simflags $cmdline \
} $
args]
58 proc sim_wait
{ dest timeout
} {
59 return [remote_wait host $timeout
]
62 proc sim_load
{ dest prog
args } {
64 if { [llength $
args] > 1 } {
65 if { [lindex $
args 1] ne
"" } {
66 set inpfile
"[lindex $args 1]"
70 if {![file
exists $prog
]} then {
71 perror
"sim.exp: $prog to be downloaded does not exist."
72 verbose
-log "$prog to be downloaded does not exist." 3
73 return [list
"untested" ""]
76 if {[board_info $dest
exists sim_time_limit
]} {
77 set sim_time_limit
[board_info $dest sim_time_limit
]
79 set sim_time_limit
240
84 if { [board_info target sim
,protocol
] eq
"sid" } {
85 set cmd
"-e \"set cpu-loader file [list $prog]\""
86 } elseif
{ [board_info target sim
,protocol
] eq
"rawsid" } {
87 set cmd
"--load=$prog"
92 # Run the
program with a limited amount of real time.
While
93 # this isn
't as nice as limiting the amount of CPU time, it
95 if { $inpfile ne "" } {
96 set res [remote_spawn target "$cmd < $inpfile" "readonly"]
98 set res [remote_spawn target $cmd]
102 return [list "fail" "remote_spawn failed"]
105 set state [remote_wait target $sim_time_limit]
106 set status [lindex $state 0]
107 set output [lindex $state 1]
108 verbose "Output is $output"
110 set status2 [check_for_board_status output]
111 if { $status2 >= 0 } {
115 verbose "Return status was: $status" 2
116 if { $status == 0 } {
121 return [list $result $output]
124 proc sim_download { dest file args } {
125 return [remote_download host $file $args]
128 proc sim_upload { dest srcfile args } {
129 return [remote_upload host $srcfile $args]
132 proc sim_exec { dest srcfile args } {
133 perror "Remote execution for simulators not implemented."
134 verbose -log "Remote execution for simulators not implemented."
138 proc sim_file { board args } {
139 return [eval [list remote_file host] $args]
142 set_board_info protocol "sim"
144 # By default, assume the simulator is slow. This causes some tests
145 # to either be simplified or skipped completely.
146 set_board_info slow_simulator 1