~ubuntu-branches/ubuntu/oneiric/dejagnu/oneiric

« back to all changes in this revision

Viewing changes to lib/tip.exp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Jacobowitz
  • Date: 2006-12-11 09:06:59 UTC
  • mfrom: (2.1.6 edgy)
  • Revision ID: james.westby@ubuntu.com-20061211090659-w586kgi3giz84053
Tags: 1.4.4.cvs20060709-3
* Acknowledge previous NMUs.
* Fix permissions on /usr/share/dejagnu when building without fakeroot
  (Closes: #392589, #379809).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2
 
# 2001, 2002, 2003 Free Software Foundation, Inc.
 
2
# 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
3
3
#
4
4
# This file is part of DejaGnu.
5
5
#
15
15
#
16
16
# You should have received a copy of the GNU General Public License
17
17
# along with DejaGnu; if not, write to the Free Software Foundation,
18
 
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
18
# Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
19
19
 
20
 
#
21
 
# Connect via tip as part of remote_open.
22
 
# returns -1 if it failed, the spawn_id if it worked; also sets
23
 
# [board_info ${hostname} fileid] with the spawn_id on success.
 
20
# Connect to HOSTNAME using tip(1).  Sets the board's fileid field
 
21
# with the spawn_id on success and returns the spawn id, otherwise
 
22
# returns -1.
24
23
#
25
24
proc tip_open { hostname } {
26
25
    global verbose
29
28
    set tries 0
30
29
    set result -1
31
30
 
32
 
    if [board_info $hostname exists name] {
 
31
    if {[board_info $hostname exists name]} {
33
32
        set hostname [board_info ${hostname} name]
34
33
    }
35
34
    set port [board_info ${hostname} tipname]
36
 
    if [board_info ${hostname} exists shell_prompt] {
 
35
    if {[board_info ${hostname} exists shell_prompt]} {
37
36
        set shell_prompt [board_info ${hostname} shell_prompt]
38
37
    } else {
39
 
        set shell_prompt ".*> " # Pick something reasonably generic.
 
38
        # Pick something reasonably generic.
 
39
        set shell_prompt ".*> "
40
40
    }
41
41
 
42
 
    if [board_info ${hostname} exists fileid] {
 
42
    if {[board_info ${hostname} exists fileid]} {
43
43
        unset board_info(${hostname},fileid)
44
44
    }
45
45
    spawn tip -v $port
119
119
    }
120
120
}
121
121
 
122
 
#
123
 
# Downloads using the ~put command under tip
124
 
#     arg - is a full path name to the file to download
125
 
#     returns -1 if an error occured, otherwise it returns 0.
 
122
# Download FILE to DEST using the ~put command in tip(1).
 
123
# Returns -1 if an error occurred, otherwise returns 0.
126
124
#
127
125
proc tip_download { dest file args } {
128
126
    global verbose
129
127
    global decimal
130
128
    global expect_out
131
129
 
132
 
    if [board_info $dest exists shell_prompt] {
 
130
    if {[board_info $dest exists shell_prompt]} {
133
131
        set shell_prompt [board_info $dest shell_prompt]
134
132
    } else {
135
133
        set shell_prompt ".*>"
136
134
    }
137
135
 
138
136
    set result ""
139
 
    if ![board_info $dest exists fileid] {
 
137
    if {![board_info $dest exists fileid]} {
140
138
        perror "tip_download: no connection to $dest."
141
139
        return $result
142
140
    }
143
141
    set shell_id [board_info $dest fileid]
144
142
 
145
 
    if ![file exists $file] {
 
143
    if {![file exists $file]} {
146
144
        perror "$file doesn't exist."
147
145
        return $result
148
146
    }
165
163
                    warning "Got an invalid command to the remote shell."
166
164
                }
167
165
                -i $shell_id -re ".*$decimal\r" {
168
 
                    if [info exists expect_out(buffer)] {
 
166
                    if {[info exists expect_out(buffer)]} {
169
167
                        verbose "$expect_out(buffer)"
170
168
                        exp_continue
171
169
                    }