1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
# Copyright (C) 92, 1993, 1994, 1996, 1997, 1998 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Please email any bugs, comments, and/or additions to this file to:
# bug-gcc@prep.ai.mit.edu
# This file was written by Rob Savoye. (rob@cygnus.com)
if ![info exists board] {
error "must set $board before loading unix.exp"
}
# For rcp_download, rsh_exec.
load_lib remote.exp
#
# unix_load -- load the program and execute it
#
# See default.exp for explanation of arguments and results.
#
proc unix_load { dest prog args } {
global ld_library_path
set output "";
if { [llength $args] > 0 } {
set parg [lindex $args 0];
} else {
set parg ""
}
if { [llength $args] > 1 } {
set inp [lindex $args 1];
} else {
set inp ""
}
if ![file exists $prog] then {
# We call both here because this should never happen.
perror "$prog does not exist in unix_load."
verbose -log "$prog does not exist." 3
return "untested"
}
verbose "loading to $dest" 2
if ![is_remote $dest] {
if { "$inp" != "" } {
set command "$prog $parg < $inp"
} else {
set command "$prog $parg";
}
if [info exists ld_library_path] {
setenv LD_LIBRARY_PATH $ld_library_path
setenv SHLIB_PATH $ld_library_path
}
set id [remote_spawn $dest "$command" "readonly"];
if { $id < 0 } {
set output "remote_spawn failed"
set status -1;
} else {
set status [remote_wait $dest 300];
set output [lindex $status 1];
set status [lindex $status 0];
}
# Unset them so we don't potentially get hosed when we try to run a
# non-testcase executable. (Setting LD_LIBRARY_PATH is the wrong
# fix in the first place; this just tries to minimize the resulting
# crap.)
if [info exists ld_library_path] {
unsetenv LD_LIBRARY_PATH
unsetenv SHLIB_PATH
}
} else {
set remotefile "/tmp/[file tail $prog].[pid]"
set remotefile [remote_download $dest $prog $remotefile];
if { $remotefile == "" } {
verbose -log "Download of $prog to [board_info $dest name] failed." 3
return [list "unresolved" ""];
}
if [board_info $dest exists remote_link] {
if [[board_info $dest remote_link] $remotefile] {
verbose -log "Couldn't do remote link"
remote_exec $dest "\\rm -f $remotefile"
return [list "unresolved" ""]
}
verbose "$prog linked ok" 3
} else {
# rcp's to lynx seem not to get marked executable
set status [remote_exec $dest "chmod +x $remotefile"]
if { [lindex $status 0] != 0 } {
remote_file $dest delete ${remotefile}.o $remotefile
verbose -log "chmod +x of $prog on $dest failed." 3
return [list "unresolved" ""];
}
}
set status [remote_exec $dest "$remotefile" $parg $inp]
remote_file $dest delete $remotefile.o $remotefile;
if { [lindex $status 0] < 0 } {
verbose -log "Couldn't execute $prog, [lindex $status 1]" 3
return [list "unresolved" ""]
}
set output [lindex $status 1]
set status [lindex $status 0]
}
verbose "Executed $prog, status $status" 2
if ![string match "" $output] {
verbose -- "$output" 2
}
if { $status == 0 } {
set result "pass";
} else {
set result "fail";
}
return [list $result $output];
}
set_board_info protocol "unix";
|