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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [dejagnu/] [config/] [unix.exp] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# Copyright (C) 92, 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-gcc@prep.ai.mit.edu
19
 
20
# This file was written by Rob Savoye. (rob@cygnus.com)
21
 
22
if ![info exists board] {
23
    error "must set $board before loading unix.exp"
24
}
25
 
26
# For rcp_download, rsh_exec.
27
load_lib remote.exp
28
 
29
#
30
# unix_load -- load the program and execute it
31
#
32
# See default.exp for explanation of arguments and results.
33
#
34
 
35
 
36
proc unix_load { dest prog args } {
37
    global ld_library_path
38
    set output "";
39
 
40
    if { [llength $args] > 0 } {
41
        set parg [lindex $args 0];
42
    } else {
43
        set parg ""
44
    }
45
 
46
    if { [llength $args] > 1 } {
47
        set inp [lindex $args 1];
48
    } else {
49
        set inp ""
50
    }
51
 
52
    if ![file exists $prog] then {
53
        # We call both here because this should never happen.
54
        perror "$prog does not exist in unix_load."
55
        verbose -log "$prog does not exist." 3
56
        return "untested"
57
    }
58
    verbose "loading to $dest" 2
59
    if ![is_remote $dest] {
60
        if { "$inp" != "" } {
61
            set command "$prog $parg < $inp"
62
        } else {
63
            set command "$prog $parg";
64
        }
65
 
66
        if [info exists ld_library_path] {
67
            setenv LD_LIBRARY_PATH $ld_library_path
68
            setenv SHLIB_PATH $ld_library_path
69
        }
70
 
71
        set id [remote_spawn $dest "$command" "readonly"];
72
        if { $id < 0 } {
73
            set output "remote_spawn failed"
74
            set status -1;
75
        } else {
76
            set status [remote_wait $dest 300];
77
            set output [lindex $status 1];
78
            set status [lindex $status 0];
79
        }
80
        # Unset them so we don't potentially get hosed when we try to run a
81
        # non-testcase executable. (Setting LD_LIBRARY_PATH is the wrong
82
        # fix in the first place; this just tries to minimize the resulting
83
        # crap.)
84
        if [info exists ld_library_path] {
85
            unsetenv LD_LIBRARY_PATH
86
            unsetenv SHLIB_PATH
87
        }
88
    } else {
89
        set remotefile "/tmp/[file tail $prog].[pid]"
90
        set remotefile [remote_download $dest $prog $remotefile];
91
        if { $remotefile == "" } {
92
            verbose -log "Download of $prog to [board_info $dest name] failed." 3
93
            return [list "unresolved" ""];
94
        }
95
        if [board_info $dest exists remote_link] {
96
            if [[board_info $dest remote_link] $remotefile] {
97
                verbose -log "Couldn't do remote link"
98
                remote_exec $dest "\\rm -f $remotefile"
99
                return [list "unresolved" ""]
100
            }
101
 
102
            verbose "$prog linked ok" 3
103
        } else {
104
            # rcp's to lynx seem not to get marked executable
105
            set status [remote_exec $dest "chmod +x $remotefile"]
106
            if { [lindex $status 0] != 0 } {
107
                remote_file $dest delete ${remotefile}.o $remotefile
108
                verbose -log "chmod +x of $prog on $dest failed." 3
109
                return [list "unresolved" ""];
110
            }
111
        }
112
        set status [remote_exec $dest "$remotefile" $parg $inp]
113
        remote_file $dest delete $remotefile.o $remotefile;
114
        if { [lindex $status 0] < 0 } {
115
            verbose -log "Couldn't execute $prog, [lindex $status 1]" 3
116
            return [list "unresolved" ""]
117
        }
118
        set output [lindex $status 1]
119
        set status [lindex $status 0]
120
    }
121
 
122
    verbose "Executed $prog, status $status" 2
123
    if ![string match "" $output] {
124
        verbose -- "$output" 2
125
    }
126
    if { $status == 0 } {
127
        set result "pass";
128
    } else {
129
        set result "fail";
130
    }
131
    return [list $result $output];
132
}
133
 
134
set_board_info protocol  "unix";

powered by: WebSVN 2.1.0

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