OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [dejagnu/] [config/] [sim.exp] - Blame information for rev 1776

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# Copyright (C) 1993, 1994, 1996, 1997, 1998 Free Software Foundation, Inc.
2
 
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.
12
#
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.
16
 
17
# Please email any bugs, comments, and/or additions to this file to:
18
# bug-dejagnu@prep.ai.mit.edu
19
 
20
#
21
# sim_load -- load the program and execute it
22
#
23
# See default.exp for explanation of arguments and results.
24
#
25
 
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];
32
    }
33
 
34
    if [board_info $dest exists sim,options] {
35
        set simflags [board_info $dest sim,options]
36
    } else {
37
        set simflags ""
38
    }
39
 
40
    if ![is_remote host] {
41
        if { [which $sim] == 0 } {
42
            verbose -log "Simulator $sim missing." 3
43
            return -1;
44
        }
45
    }
46
 
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]
54
    }
55
 
56
    return [eval remote_spawn host \{ $sim $simflags $cmdline \} $args];
57
}
58
 
59
proc sim_wait { dest timeout } {
60
    return [remote_wait host $timeout];
61
}
62
 
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]"
68
        }
69
    }
70
 
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" ""];
75
    }
76
 
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
81
    }
82
 
83
    set output "";
84
 
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}"];
92
    }
93
 
94
    if { $res <= 0 } {
95
        return [list "fail" "remote_spawn failed"];
96
    }
97
 
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";
102
 
103
    set status2 [check_for_board_status output];
104
    if { $status2 >= 0 } {
105
        set status $status2
106
    }
107
 
108
    # FIXME: Do we need to examine $status?
109
    # Yes, we do--what if the simulator itself gets an error and coredumps?
110
 
111
    verbose "Return status was: $status" 2
112
    if { $status == 0 } {
113
        set result "pass"
114
    } else {
115
        set result "fail"
116
    }
117
    return [list $result $output];
118
}
119
 
120
set_board_info protocol  "sim";
121
 
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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.