1 # Copyright
(C
) 1992-2019, 2020 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
, see
<http
://www.gnu.org
/licenses
/>.
18 #
Connect to HOSTNAME using tip
(1). Sets the board
's fileid field
19 # with the spawn_id on success and returns the spawn id, otherwise
22 proc tip_open { hostname } {
29 if {[board_info $hostname exists name]} {
30 set hostname [board_info $hostname name]
32 set port [board_info $hostname tipname]
33 if {[board_info $hostname exists shell_prompt]} {
34 set shell_prompt [board_info $hostname shell_prompt]
36 # Pick something reasonably generic.
37 set shell_prompt ".*> "
40 if {[board_info $hostname exists fileid]} {
41 unset board_info($hostname,fileid)
44 if { $spawn_id < 0 } {
45 perror "invalid spawn id from tip"
49 -re ".*connected.*$" {
52 -re ".*$shell_prompt.*$" {
53 verbose "Got prompt\n"
58 warning "Never got prompt."
67 -re "all ports busy.*$" {
69 perror "All ports busy."
75 -re "Connection Closed.*$" {
76 perror "Never connected."
83 -re ".*: Permission denied.*link down.*$" {
89 perror "Timed out trying to connect."
97 perror "Got unexpected EOF from tip."
106 verbose "Setting verbose mode" 1
112 perror "Couldn't
connect after $tries tries.
"
115 set board_info
($hostname
,fileid
) $spawn_id
120 # Download FILE to DEST using the ~put command in tip
(1).
121 # Returns
-1 if an error occurred
, otherwise returns
0.
123 proc tip_download
{ dest file
args } {
128 if {[board_info $dest
exists shell_prompt
]} {
129 set shell_prompt
[board_info $dest shell_prompt
]
131 set shell_prompt
".*>"
135 if {![board_info $dest
exists fileid
]} {
136 perror
"tip_download: no connection to $dest."
139 set shell_id
[board_info $dest fileid
]
141 if {![file
exists $file
]} {
142 perror
"$file doesn't exist."
146 send
-i $shell_id
"\n~p"
148 -i $shell_id
"~\[put\]*" {
149 verbose
"Downloading $file, please wait" 1
150 send
-i $shell_id
"$file\n"
153 -i $shell_id
-re
".*$file.*$" {
156 -i $shell_id
-re
".*lines transferred in.*minute.*seconds.*$shell_prompt.*$" {
157 verbose
"Download $file successfully" 1
160 -i $shell_id
-re
".*Invalid command.*$shell_prompt$" {
161 warning
"Got an invalid command to the remote shell."
163 -i $shell_id
-re
".*$decimal\r" {
164 if {[info exists expect_out
(buffer
)]} {
165 verbose $expect_out
(buffer
)
169 -i $shell_id timeout
{
170 perror
"Timed out trying to download."
175 perror
"Timed out waiting for response to put command."