You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

176 lines
4.4 KiB

* configure.ac, dejagnu.h, runtest, runtest.exp, baseboards/am33_2.0-libremote.exp, baseboards/androideabi.exp, baseboards/arm-ice.exp, baseboards/arm-sid.exp, baseboards/arm-sim.exp, baseboards/basic-sid.exp, baseboards/basic-sim.exp, baseboards/cris-sim.exp, baseboards/d30v-sim.exp, baseboards/fr30-sim.exp, baseboards/frv-sim.exp, baseboards/gdbserver-sample.exp, baseboards/i386-sid.exp, baseboards/iq2000-sim.exp, baseboards/jmr3904-sim.exp, baseboards/linux-gdbserver.exp, baseboards/linux-libremote.exp, baseboards/m68k-sid.exp, baseboards/mcore-moto-sim.exp, baseboards/mcore-sim.exp, baseboards/mips-lnews-sim.exp, baseboards/mips-lsi-sim.exp, baseboards/mips-sim-idt32.exp, baseboards/mips-sim-idt64.exp, baseboards/mips-sim-mti32.exp, baseboards/mips-sim-mti64.exp, baseboards/mips-sim-mti64_64.exp, baseboards/mips-sim-mti64_n32.exp, baseboards/mips-sim-sde32.exp, baseboards/mips-sim-sde64.exp, baseboards/mips-sim.exp, baseboards/mmixware-sim.exp, baseboards/mn10200-sim.exp, baseboards/mn10300-sim.exp, baseboards/moxie-sim.exp, baseboards/mt-sid.exp, baseboards/multi-sim.exp, baseboards/powerpc-sim.exp, baseboards/powerpcle-sim.exp, baseboards/rx-sim.exp, baseboards/sh-sid.exp, baseboards/sh-sim.exp, baseboards/sparc-sim.exp, baseboards/sparc64-sim.exp, baseboards/sparclite-sim-le.exp, baseboards/sparclite-sim.exp, baseboards/tx39-sim.exp, baseboards/unix.exp, baseboards/v850-sim.exp, baseboards/visium-sim.exp, baseboards/vr4100-sim.exp, baseboards/vr4111-sim.exp, baseboards/vr4300-sim.exp, baseboards/xtensa-sim.exp, lib/debugger.exp, lib/dejagnu.exp, lib/dg.exp, lib/ftp.exp, lib/kermit.exp, lib/remote.exp, lib/rlogin.exp, lib/rsh.exp, lib/standard.exp, lib/target.exp, lib/targetdb.exp, lib/telnet.exp, lib/tip.exp, lib/utils.exp, testsuite/config/default.exp, testsuite/lib/libsup.exp, testsuite/lib/util-defs.exp, testsuite/libdejagnu/tunit.exp, testsuite/libdejagnu/unit.cc, testsuite/runtest.all/libs.exp, testsuite/runtest.all/stats-sub.exp, testsuite/runtest.all/stats.exp, config/adb.exp, config/default.exp, config/gdb-comm.exp, config/gdb_stub.exp, config/sid.exp, config/sim.exp, config/unix.exp, config/vxworks.exp: Update copyright date for 2016. Signed-off-by: Ben Elliston <bje@gnu.org>
10 years ago
# Copyright (C) 1992-2016 Free Software Foundation, Inc.
#
# This file is part of DejaGnu.
#
# DejaGnu 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 3 of the License, or
26 years ago
# (at your option) any later version.
23 years ago
#
# DejaGnu 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.
23 years ago
#
26 years ago
# You should have received a copy of the GNU General Public License
# along with DejaGnu; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
26 years ago
# Connect to DEST using Kermit. Note that we're just using Kermit as a
26 years ago
# simple serial or network connect program; we don't actually use Kermit
# protocol to do downloads.
#
# Returns -1 if it failed, otherwise it returns the spawn_id.
#
proc kermit_open {dest args} {
26 years ago
global spawn_id
global board_info
if {[board_info $dest exists name]} {
set dest [board_info $dest name]
26 years ago
}
if {[board_info ${dest} exists serial]} {
set port [board_info ${dest} serial]
26 years ago
set device "-l [board_info ${dest} serial]"
if {[board_info ${dest} exists baud]} {
26 years ago
append device " -b [board_info ${dest} baud]"
}
} else {
set port [board_info ${dest} netport]
set device "-j [board_info ${dest} netport]"
26 years ago
}
23 years ago
26 years ago
set tries 0
set result -1
verbose "kermit $device"
eval spawn kermit $device
if {$spawn_id < 0} {
perror "invalid spawn id from Kermit"
26 years ago
return -1
}
expect {
23 years ago
-re ".*ermit.*>.*$" {
26 years ago
send "c\n"
expect {
-re "Connecting to.*$port.*Type the escape character followed by C to.*options.*\[\r\n\]$" {
verbose "Got prompt\n"
set result 0
incr tries
}
timeout {
warning "Never got prompt from Kermit."
set result -1
incr tries
if {$tries <= 2} {
26 years ago
exp_continue
}
}
}
}
-re "Connection Closed.*$" {
perror "Never connected."
set result -1
incr tries
if {$tries <= 2} {
26 years ago
exp_continue
}
}
23 years ago
timeout {
26 years ago
warning "Timed out trying to connect."
set result -1
incr tries
if {$tries <= 2} {
26 years ago
exp_continue
}
}
}
if {$result < 0} {
26 years ago
perror "Couldn't connect after $tries tries."
if {[info exists board_info($dest,fileid)]} {
unset board_info($dest,fileid)
26 years ago
}
return -1
} else {
verbose "Kermit connection established with spawn_id $spawn_id."
set board_info($dest,fileid) $spawn_id
kermit_command $dest "set file type binary" "set transfer display none"
if {[board_info $dest exists transmit_pause]} {
26 years ago
kermit_command $dest "set transmit pause [board_info $dest transmit_pause]"
}
return $spawn_id
}
}
# Send a list of commands to the Kermit session connected to DEST.
#
proc kermit_command {dest args} {
if {[board_info $dest exists name]} {
set dest [board_info $dest name]
26 years ago
}
set shell_id [board_info $dest fileid]
26 years ago
# Sometimes we have to send multiple ^\c sequences. Don't know
# why.
set timeout 2
for {set i 1} {$i <= 5} {incr i} {
send -i $shell_id "c"
26 years ago
expect {
-i $shell_id -re ".*Back at.*ermit.*>.*$" {set i 10}
26 years ago
-i $shell_id timeout {
if {$i > 2} {
warning "Unable to get prompt from kermit."
26 years ago
}
}
}
}
foreach command $args {
set timeout 120
send -i $shell_id "${command}\r"
26 years ago
expect {
-i $shell_id -re ".*ermit.*>.*$" { }
-i $shell_id timeout {
perror "Response failed from Kermit."
return -1
26 years ago
}
}
}
send -i $shell_id "c\r"
26 years ago
expect {
-i $shell_id -re ".*other options.\[\r\n\]+" { }
-i $shell_id timeout {
perror "Unable to resume Kermit connection."
return -1
26 years ago
}
}
return 0
26 years ago
}
# Send STRING to DEST.
#
proc kermit_send {dest string args} {
if {[board_info $dest exists transmit_pause]} {
set f [open "/tmp/fff" "w"]
puts -nonewline $f "$string"
close $f
set result [remote_transmit $dest /tmp/fff]
remote_file build delete "/tmp/fff"
return "$result"
26 years ago
} else {
return [standard_send $dest $string]
26 years ago
}
}
# Transmit FILE directly to DEST as raw data.
# No translation is performed.
26 years ago
#
proc kermit_transmit {dest file args} {
if {[board_info $dest exists transmit_pause]} {
kermit_command $dest "transmit $file"
return ""
26 years ago
} else {
return [standard_transmit $dest $file]
26 years ago
}
}