From 8bd9e0e9da1fadb663b268cb061ea7540935b18c Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Wed, 27 Feb 2002 05:33:07 +0000 Subject: [PATCH] Wed Nov 21 18:02:49 PST 2001 Brendan Conoboy * lib/rsh.exp: Obey rsh_prog/rcp_prog, support username * lib/remote.exp: same. --- ChangeLog | 5 +++ lib/remote.exp | 34 ++++++++++++-- lib/rsh.exp | 140 ++++++++++++++++++++++++++++++++++++--------------------- 3 files changed, 126 insertions(+), 53 deletions(-) diff --git a/ChangeLog b/ChangeLog index aefbb34..835bf9f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Nov 21 18:02:49 PST 2001 Brendan Conoboy + + * lib/rsh.exp: Obey rsh_prog/rcp_prog, support username + * lib/remote.exp: same. + 2002-02-22 Bob Wilson * baseboards/xtensa-sim.exp: New file. diff --git a/lib/remote.exp b/lib/remote.exp index d9c5c9d..a209930 100644 --- a/lib/remote.exp +++ b/lib/remote.exp @@ -442,6 +442,7 @@ proc call_remote { type proc dest args } { if [board_info $dest exists name] { set dest [board_info $dest name]; } +verbose "In call_remote with $dest, $args" if { $dest != "host" && $dest != "build" && $dest != "target" } { if { ![board_info $dest exists name] } { @@ -781,12 +782,29 @@ proc remote_raw_spawn { dest commandline } { proc standard_spawn { dest commandline } { global board_info + if ![board_info $dest exists rsh_prog] { + if { [which remsh] != 0 } { + set RSH remsh + } else { + set RSH rsh + } + } else { + set RSH [board_info $dest rsh_prog]; + } + + if ![board_info $dest exists username] { + set rsh_useropts "" + } else { + set rsh_useropts "-l $username" + } + if [board_info $dest exists hostname] { set remote [board_info $dest hostname]; } else { set remote $dest; } - spawn rsh $remote $commandline; + + spawn $RSH $rsh_useropts $remote $commandline; set board_info($dest,fileid) $spawn_id; return $spawn_id; } @@ -1050,6 +1068,16 @@ proc standard_wait { dest timeout } { proc check_for_board_status { variable } { upvar $variable output; + # If all programs of this board have a wrapper that always outputs a + # status message, then the absence of it means that the program + # crashed, regardless of status found elsewhere (e.g. simulator exit + # code). + if { [target_info needs_status_wrapper] != "" } then { + set nomatch_return 2 + } else { + set nomatch_return -1 + } + if [regexp "(^|\[\r\n\])\\*\\*\\* EXIT code" $output] { regsub "^.*\\*\\*\\* EXIT code " $output "" result; regsub "\[\r\n\].*$" $result "" result; @@ -1059,12 +1087,12 @@ proc check_for_board_status { variable } { verbose "got board status $result" 3 verbose "output is $output" 3 if { $result == "" } { - return -1; + return $nomatch_return; } else { return [expr $result]; } } else { - return -1; + return $nomatch_return; } } diff --git a/lib/rsh.exp b/lib/rsh.exp index 13c0feb..70f4af9 100644 --- a/lib/rsh.exp +++ b/lib/rsh.exp @@ -26,6 +26,22 @@ proc rsh_open { hostname } { set tries 0 set result -1 + if ![board_info $hostname exists rsh_prog] { + if { [which remsh] != 0 } { + set RSH remsh + } else { + set RSH rsh + } + } else { + set RSH [board_info $hostname rsh_prog]; + } + + if [board_info $hostname exists username] { + set rsh_useropts "-l [board_info $hostname username]" + } else { + set rsh_useropts "" + } + # get the hostname and port number from the config array if [board_info $hostname exists name] { set hostname [board_info $hostname name]; @@ -41,19 +57,9 @@ proc rsh_open { hostname } { unset board_info($hostname,fileid); } - if ![board_info $hostname exists rsh_prog] { - if { [which remsh] != 0 } { - set RSH remsh - } else { - set RSH rsh - } - } else { - set RSH [board_info $hostname rsh_prog]; - } - - spawn $RSH $hostname + spawn $RSH $rsh_useropts $hostname if { $spawn_id < 0 } { - perror "invalid spawn id from rsh" + perror "invalid spawn id from $RSH" return -1 } @@ -80,48 +86,48 @@ proc rsh_open { hostname } { exp_continue } -re "isn't registered for Kerberos.*service.*$" { - warning "rsh: isn't registered for Kerberos, please kinit" + warning "$RSH: isn't registered for Kerberos, please kinit" catch close catch wait break } -re "Kerberos rcmd failed.*$" { - warning "rsh: Kerberos rcmd failed, please kinit" + warning "$RSH: Kerberos rcmd failed, please kinit" catch close catch wait break } -re "You have no Kerberos tickets.*$" { - warning "rsh: No kerberos Tickets, please kinit" + warning "$RSH: No kerberos Tickets, please kinit" catch close catch wait break } "Terminal type is" { - verbose "rsh: connected, got terminal prompt" 2 + verbose "$RSH: connected, got terminal prompt" 2 set result 0 break } -re "trying normal rlogin.*$" { - warning "rsh: trying normal rlogin." + warning "$RSH: trying normal rlogin." catch close catch wait break } -re "unencrypted connection.*$" { - warning "rsh: unencrypted connection, please kinit" + warning "$RSH: unencrypted connection, please kinit" catch close catch wait break } -re "Sorry, shell is locked.*Connection closed.*$" { - warning "rsh: already connected." + warning "$RSH: already connected." } timeout { - warning "rsh: timed out trying to connect." + warning "$RSH: timed out trying to connect." } eof { - perror "rsh: got EOF while trying to connect." + perror "$RSH: got EOF while trying to connect." break } } @@ -129,7 +135,7 @@ proc rsh_open { hostname } { } if { $result < 0 } { -# perror "rsh: couldn't connect after $tries tries." +# perror "$RSH: couldn't connect after $tries tries." close -i $spawn_id set spawn_id -1 } else { @@ -144,6 +150,31 @@ proc rsh_open { hostname } { # proc rsh_download {desthost srcfile destfile} { + # must be done before desthost is rewritten + if [board_info $desthost exists rcp_prog] { + set RCP [board_info $desthost rcp_prog]; + } else { + set RCP rcp + } + + if [board_info $desthost exists rsh_prog] { + set RSH [board_info $desthost rsh_prog]; + } else { + if { [which remsh] != 0 } { + set RSH remsh + } else { + set RSH rsh + } + } + + if [board_info $desthost exists username] { + set rsh_useropts "-l [board_info $desthost username]" + set rcp_user "[board_info $desthost username]@" + } else { + set rsh_useropts "" + set rcp_user "" + } + if [board_info $desthost exists name] { set desthost [board_info $desthost name]; } @@ -152,13 +183,8 @@ proc rsh_download {desthost srcfile destfile} { set desthost [board_info $desthost hostname]; } - if ![board_info $desthost exists rcp_prog] { - set RCP rcp - } else { - set RCP [board_info $desthost rcp_prog]; - } - - set status [catch "exec $RCP $srcfile $desthost:$destfile |& cat" output] + set status [catch "exec $RSH $rsh_useropts $desthost rm -f $destfile |& cat" output] + set status [catch "exec $RCP $srcfile $rcp_user$desthost:$destfile |& cat" output] if { $status == 0 } { verbose "Copied $srcfile to $desthost:$destfile" 2 return $destfile; @@ -169,6 +195,18 @@ proc rsh_download {desthost srcfile destfile} { } proc rsh_upload {desthost srcfile destfile} { + if [board_info $desthost exists rcp_prog] { + set RCP [board_info $desthost rcp_prog]; + } else { + set RCP rcp + } + + if [board_info $desthost exists username] { + set rcp_user "[board_info $desthost username]@" + } else { + set rcp_user "" + } + if [board_info $desthost exists name] { set desthost [board_info $desthost name]; } @@ -177,13 +215,7 @@ proc rsh_upload {desthost srcfile destfile} { set desthost [board_info $desthost hostname]; } - if ![board_info $desthost exists rcp_prog] { - set RCP rcp - } else { - set RCP [board_info $desthost rcp_prog]; - } - - set status [catch "exec $RCP $desthost:$srcfile $destfile" output]; + set status [catch "exec $RCP $rcp_user$desthost:$srcfile $destfile" output]; if { $status == 0 } { verbose "Copied $desthost:$srcfile to $destfile" 2 return $destfile; @@ -211,6 +243,22 @@ proc rsh_exec { boardname cmd args } { verbose "Executing $boardname:$cmd $pargs < $inp" + if ![board_info $boardname exists rsh_prog] { + if { [which remsh] != 0 } { + set RSH remsh + } else { + set RSH rsh + } + } else { + set RSH [board_info $boardname rsh_prog]; + } + + if [board_info $boardname exists username] { + set rsh_useropts "-l [board_info $boardname username]" + } else { + set rsh_useropts "" + } + if [board_info $boardname exists name] { set boardname [board_info $boardname name]; } @@ -221,34 +269,26 @@ proc rsh_exec { boardname cmd args } { set hostname $boardname; } - if ![board_info $hostname exists rsh_prog] { - if { [which remsh] != 0 } { - set RSH remsh - } else { - set RSH rsh - } - } else { - set RSH [board_info $hostname rsh_prog]; - } - + # If CMD sends any output to stderr, exec will think it failed. More often # than not that will be true, but it doesn't catch the case where there is # no output but the exit code is non-zero. if { $inp == "" } { set inp "/dev/null" } - set status [catch "exec cat $inp | $RSH $boardname sh -c '$cmd $pargs \\; echo XYZ\\\${?}ZYX' |& cat" output] - verbose "rsh output is $output" + + set status [catch "exec cat $inp | $RSH $rsh_useropts $hostname sh -c '$cmd $pargs \\; echo XYZ\\\${?}ZYX' |& cat" output] + verbose "$RSH output is $output" # `status' doesn't mean much here other than rsh worked ok. # What we want is whether $cmd ran ok. if { $status != 0 } { regsub "XYZ(\[0-9\]*)ZYX\n?" $output "" output - return [list -1 "rsh to $boardname failed for $cmd, $output"] + return [list -1 "$RSH to $boardname failed for $cmd, $output"] } regexp "XYZ(\[0-9\]*)ZYX" $output junk status verbose "rsh_exec: status:$status text:$output" 4 if { $status == "" } { - return [list -1 "Couldn't parse rsh output, $output."] + return [list -1 "Couldn't parse $RSH output, $output."] } regsub "XYZ(\[0-9\]*)ZYX\n?" $output "" output # Delete one trailing \n because that is what `exec' will do and we want -- 2.11.4.GIT