1
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2
# 2001, 2002, 2003 Free Software Foundation, Inc.
4
# This file is part of DejaGnu.
6
# DejaGnu is free software; you can redistribute it and/or modify it
7
# under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
11
# DejaGnu is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
# General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with DejaGnu; if not, write to the Free Software Foundation,
18
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
# This file was written by Rob Savoye. (rob@welcomehome.org)
23
# Connect to udi using mondfe
25
# HOSTNAME can be `iss' to talk to the simulator.
26
# The result is the value of `spawn_id' or -1 for failure.
28
proc mondfe_open { hostname } {
35
set shell_prompt [board_info $hostname shell_prompt]
36
if ![board_info $hostname exists mondfe,name] {
37
perror "Must set board_info(${hostname},mondfe,name)"
40
if [board_info $hostname exists mondfe] {
41
set mondfe [board_info $hostname mondfe]
46
set remote_host [board_info $hostname mondfe,name]
48
if [board_info $hostname exists mondfe_host] {
49
set rh [board_info $hostname mondfe_host]
51
verbose "Attempting to connect to $hostname via mondfe."
55
set shell_id [remote_spawn $rh "$mondfe -D -TIP $remote_host"]
57
remote_expect $rh 60 {
62
"*server bind*failed: Address already in use*" {
63
warning "Socket file already exists."
65
if { $retries <= 2 } {
69
-indices -re ".*(UDIERROR\[^\r\n\]*)\[\r\n\]" {
70
warning "$expect_out(1,string)"
73
-indices -re ".*(DFEERROR\[^\r\n\]*)\[\r\n\]" {
74
warning "$expect_out(1,string)"
78
warning "Timed out trying to connect."
81
if { $retries <= 2 } {
89
perror "Couldn't connect after $retries retries."
93
set board_info($hostname,fileid) $shell_id
99
# Downloads using the y (yank) command in mondfe
101
# FILE is a full path name to the file to download.
102
# Returns 1 if an error occured, 0 otherwise.
104
proc mondfe_ld { dest_machine file } {
105
global decimal # Regexp to match a decimal number.
107
if ![file exists $file] {
108
perror "$file doesn't exist."
112
set shell_prompt [board_info $dest_machine shell_prompt]
114
if [board_info $dest_machine exists mondfe_host] {
115
set remote_host [board_info $dest_machine mondfe_host]
116
set file [remote_download $remote_host $file montest]
118
set remote_host "host"
121
verbose "Downloading $file." 2
122
verbose "Shell prompt is $shell_prompt." 3
124
remote_send $remote_host "y $file\n"
125
remote_expect $remote_host 60 {
129
-re "loading $file\[\r\n\]+" {
132
-re "Load(ing|ed) *TEXT section from\[^\r\n\]*\[\r\n\]+" {
136
-re "Load(ing|ed) *LIT section from\[^\r\n\]*\[\r\n\]+" {
140
-re "Load(ing|ed) *DATA section from\[^\r\n\]*\[\r\n\]+" {
144
-re "Clear(ing|ed) *BSS section from\[^\r\n\]*\[\r\n\]+" {
148
-re "(^|\[\r\n\]+)$shell_prompt$" {
149
verbose "Downloaded $file successfully." 2
152
-re "Command failed.*$shell_prompt$" {
155
-re "DFEWARNING: $decimal : EMMAGIC: Bad COFF file magic number.*Command failed.*$shell_prompt$" {
156
warning "Bad COFF file magic number"
159
-re "Ignoring COMMENT section \($decimal bytes\)\[^\r\n\]*\[\r\n\]+" {
160
verbose "Ignoring COMMENT section" 2
164
perror "Timed out trying to download $file."
169
if { $result && [info exists expect_out(buffer)] } {
170
send_log $expect_out(buffer)
173
if [board_info $dest_machine exists mondfe_host] {
174
remote_file $remote_machine delete $file
181
# Exit the remote shell
183
proc mondfe_close { hostname } {
186
if [board_info $hostname exists mondfe_host] {
187
set remote_host [board_info $hostname mondfe_host]
189
set remote_host "host"
192
if ![board_info $hostname exists fileid] {
196
if [board_info $remote_host exists fileid] {
197
remote_send $remote_host "q\n"
198
remote_expect $remote_host 30 {
200
verbose "Exited mondfe."
203
warning "mondfe didn't exit cleanly."
207
remote_close $remote_host
210
unset board_info($hostname,fileid)