* Makefile.am: Add an empty check-DEJAGNU target, cause we only
[dejagnu.git] / config / sim.exp
blob3143b319ffc92a8aa44f7e3afc20ed18628c859b
1 # Copyright (C) 1993 - 2001 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-dejagnu@gnu.org
21 # sim_load -- load the program and execute it
23 # See default.exp for explanation of arguments and results.
26 proc sim_spawn { dest cmdline args } {
27 if ![board_info $dest exists sim] {
28 perror "no simulator defined for [board_info $dest name]"
29 exit 1
30 } else {
31 set sim [board_info $dest sim];
34 if [board_info $dest exists sim,options] {
35 set simflags [board_info $dest sim,options]
36 } else {
37 set simflags ""
40 if ![is_remote host] {
41 if { [which $sim] == 0 } {
42 verbose -log "Simulator $sim missing." 3
43 return -1;
47 if [is_remote host] {
48 # download the program to remote.
49 # we're assuming the program is the first word in the command.
50 # FIXME: "prog < infile" won't work until we download infile.
51 set prog [lindex $cmdline 0]
52 set prog [remote_download host $prog a.out];
53 set cmdline [lreplace $cmdline 0 0 $prog]
56 return [eval remote_spawn host \{ $sim $simflags $cmdline \} $args];
59 proc sim_wait { dest timeout } {
60 return [remote_wait host $timeout];
63 proc sim_load { dest prog args } {
64 set inpfile ""
65 if { [llength $args] > 1 } {
66 if { [lindex $args 1] != "" } {
67 set inpfile "[lindex $args 1]"
71 if ![file exists $prog] then {
72 perror "sim.exp: $prog to be downloaded does not exist."
73 verbose -log "$prog to be downloaded does not exist." 3
74 return [list "untested" ""];
77 if [board_info $dest exists sim_time_limit] {
78 set sim_time_limit [board_info $dest sim_time_limit];
79 } else {
80 set sim_time_limit 240
83 set output "";
85 # Run the program with a limited amount of real time. While
86 # this isn't as nice as limiting the amount of CPU time, it
87 # will have to do.
88 if { $inpfile != "" } {
89 set res [remote_spawn target "${prog} < $inpfile" "readonly"];
90 } else {
91 set res [remote_spawn target "${prog}"];
94 if { $res <= 0 } {
95 return [list "fail" "remote_spawn failed"];
98 set state [remote_wait target $sim_time_limit];
99 set status [lindex $state 0];
100 set output [lindex $state 1];
101 verbose "Output is $output";
103 set status2 [check_for_board_status output];
104 if { $status2 >= 0 } {
105 set status $status2
108 # FIXME: Do we need to examine $status?
109 # Yes, we do--what if the simulator itself gets an error and coredumps?
111 verbose "Return status was: $status" 2
112 if { $status == 0 } {
113 set result "pass"
114 } else {
115 set result "fail"
117 return [list $result $output];
120 set_board_info protocol "sim";
122 # By default, assume the simulator is slow. This causes some tests
123 # to either be simplified or skipped completely.
124 set_board_info slow_simulator 1