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
, write to the Free Software Foundation
,
17 # Inc.
, 51 Franklin Street
- Fifth Floor
, Boston
, MA
02110-1301, USA.
19 #
Connect to HOSTNAME using tip
(1). Sets the board
's fileid field
20 # with the spawn_id on success and returns the spawn id, otherwise
23 proc tip_open { hostname } {
30 if {[board_info $hostname exists name]} {
31 set hostname [board_info $hostname name]
33 set port [board_info $hostname tipname]
34 if {[board_info $hostname exists shell_prompt]} {
35 set shell_prompt [board_info $hostname shell_prompt]
37 # Pick something reasonably generic.
38 set shell_prompt ".*> "
41 if {[board_info $hostname exists fileid]} {
42 unset board_info($hostname,fileid)
45 if { $spawn_id < 0 } {
46 perror "invalid spawn id from tip"
50 -re ".*connected.*$" {
53 -re ".*$shell_prompt.*$" {
54 verbose "Got prompt\n"
59 warning "Never got prompt."
68 -re "all ports busy.*$" {
70 perror "All ports busy."
76 -re "Connection Closed.*$" {
77 perror "Never connected."
84 -re ".*: Permission denied.*link down.*$" {
90 perror "Timed out trying to connect."
98 perror "Got unexpected EOF from tip."
107 verbose "Setting verbose mode" 1
113 perror "Couldn't
connect after $tries tries.
"
116 set board_info
($hostname
,fileid
) $spawn_id
121 # Download FILE to DEST using the ~put command in tip
(1).
122 # Returns
-1 if an error occurred
, otherwise returns
0.
124 proc tip_download
{ dest file
args } {
129 if {[board_info $dest
exists shell_prompt
]} {
130 set shell_prompt
[board_info $dest shell_prompt
]
132 set shell_prompt
".*>"
136 if {![board_info $dest
exists fileid
]} {
137 perror
"tip_download: no connection to $dest."
140 set shell_id
[board_info $dest fileid
]
142 if {![file
exists $file
]} {
143 perror
"$file doesn't exist."
147 send
-i $shell_id
"\n~p"
149 -i $shell_id
"~\[put\]*" {
150 verbose
"Downloading $file, please wait" 1
151 send
-i $shell_id
"$file\n"
154 -i $shell_id
-re
".*$file.*$" {
157 -i $shell_id
-re
".*lines transferred in.*minute.*seconds.*$shell_prompt.*$" {
158 verbose
"Download $file successfully" 1
161 -i $shell_id
-re
".*Invalid command.*$shell_prompt$" {
162 warning
"Got an invalid command to the remote shell."
164 -i $shell_id
-re
".*$decimal\r" {
165 if {[info exists expect_out
(buffer
)]} {
166 verbose $expect_out
(buffer
)
170 -i $shell_id timeout
{
171 perror
"Timed out trying to download."
176 perror
"Timed out waiting for response to put command."