dejagnu
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RSH timeout support


From: Daniel Jacobowitz
Subject: RSH timeout support
Date: Thu, 30 Mar 2006 18:38:02 -0500
User-agent: Mutt/1.5.8i

I've had this patch in my DejaGNU tree for over a year and a half now,
but never gotten around to posting it.  It updates rsh.exp to use
local_exec instead of spawn, which enables timeout support.  Handy
when running tests which actually time out!

Please apply if OK.

Oh, one interesting PITA is that the call to call_remote further down
in remote.exp uses a local variable named timeout when calling
local_exec, but does not have any way to pass it to call_remote.
I used a hack to pass the timeout through a global variable, but
that's ugly and not too important, so I didn't include it here.
call_remote taking a timeout might be a nice improvement for another
day.

-- 
Daniel Jacobowitz
CodeSourcery

2006-03-30  Daniel Jacobowitz  <address@hidden>

        * rsh.exp (rsh_exec): Handle inp and outp arguments.  Use
        local_exec to run rsh.  Return failure if rsh times out.
        * remote.exp (local_exec): Handle "|& cat" we added when
        deciding whether to return output.

Index: lib/remote.exp
===================================================================
RCS file: /cvsroot/dejagnu/dejagnu/lib/remote.exp,v
retrieving revision 1.22
diff -u -p -r1.22 remote.exp
--- lib/remote.exp      1 Jan 2006 07:00:11 -0000       1.22
+++ lib/remote.exp      30 Mar 2006 23:34:42 -0000
@@ -210,8 +210,8 @@ proc local_exec { commandline inp outp t
     } else {
        set status 0
     }
-    verbose "output is $output"
-    if { $outp == "" } {
+    verbose "output is $output status $status"
+    if { $outp == "" || $outp == "|& cat" } {
         return [list $status $output]
     } else {
         return [list $status ""]
Index: lib/rsh.exp
===================================================================
RCS file: /cvsroot/dejagnu/dejagnu/lib/rsh.exp,v
retrieving revision 1.11
diff -u -p -r1.11 rsh.exp
--- lib/rsh.exp 24 Sep 2005 06:49:55 -0000      1.11
+++ lib/rsh.exp 30 Mar 2006 23:34:42 -0000
@@ -223,20 +223,10 @@ proc rsh_upload {desthost srcfile destfi
 
 # Execute CMD on BOARDNAME.
 #
-proc rsh_exec { boardname cmd args } {
-    if { [llength $args] > 0 } {
-       set pargs [lindex $args 0]
-       if { [llength $args] > 1 } {
-           set inp [lindex $args 1]
-       } else {
-           set inp ""
-       }
-    } else {
-       set pargs ""
-       set inp ""
-    }
+proc rsh_exec { boardname program pargs inp outp } {
+    global timeout
 
-    verbose "Executing $boardname:$cmd $pargs < $inp"
+    verbose "Executing $boardname:$program $pargs < $inp"
 
     if ![board_info $boardname exists rsh_prog] {
        if { [which remsh] != 0 } {
@@ -271,13 +261,20 @@ proc rsh_exec { boardname cmd args } {
        set inp "/dev/null"
     }
 
-    set status [catch "exec cat $inp | $RSH $rsh_useropts $hostname sh -c 
'$cmd $pargs \\; echo XYZ\\\${?}ZYX' |& cat" output]
-    verbose "$RSH output is $output"
+    set ret [local_exec "$RSH $rsh_useropts $hostname sh -c '$program $pargs 
\\; echo XYZ\\\${?}ZYX'" $inp $outp $timeout]
+    set status [lindex $ret 0]
+    set output [lindex $ret 1]
+
+    verbose "$RSH status is $status, output is $output"
+
     # `status' doesn't mean much here other than rsh worked ok.
-    # What we want is whether $cmd ran ok.
+    # What we want is whether $program ran ok.  Return $status;
+    # if the program timed out, status will be 1 indicating that
+    # rsh ran and failed.  If rsh fails, we will get FAIL rather
+    # than UNRESOLVED - this will help the problem be noticed.
     if { $status != 0 } {
        regsub "XYZ(\[0-9\]*)ZYX\n?" $output "" output
-       return [list -1 "$RSH to $boardname failed for $cmd, $output"]
+       return [list $status "$RSH to $boardname failed for $program, $output"]
     }
     regexp "XYZ(\[0-9\]*)ZYX" $output junk status
     verbose "rsh_exec: status:$status text:$output" 4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]