/[dejagnu]/dejagnu/lib/remote.exp
ViewVC logotype

Diff of /dejagnu/lib/remote.exp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by rsavoye, Tue Jul 16 23:06:21 2002 UTC revision 1.10 by rsavoye, Mon Mar 17 02:25:07 2003 UTC
# Line 1  Line 1 
1  # Copyright (C) 1992 - 2001, 2002 Free Software Foundation, Inc.  # Copyright (C) 1992 - 2002, 2003 Free Software Foundation, Inc.
2    
3  # This program is free software; you can redistribute it and/or modify  # This program is free software; you can redistribute it and/or modify
4  # it under the terms of the GNU General Public License as published by  # it under the terms of the GNU General Public License as published by
# Line 179  proc local_exec { commandline inp outp t Line 179  proc local_exec { commandline inp outp t
179      # command in order to execute the execution. (English. Gotta love it.)      # command in order to execute the execution. (English. Gotta love it.)
180      if { ! $got_eof } {      if { ! $got_eof } {
181          verbose "killing $pid $pgid";          verbose "killing $pid $pgid";
182          exec sh -c "exec > /dev/null 2>&1 && (kill -2 $pgid || kill -2 $pid) && sleep 5 && (kill -15 $pgid || kill $pid) && sleep 5 && (kill -9 $pgid || kill -9 $pid)" &;          # This is very, very nasty. SH, instead of EXPECT, is used to
183            # run this in the background since, on older CYGWINs, a
184            # strange file I/O error occures.
185            exec sh -c "exec > /dev/null 2>&1 && (kill -2 $pgid || kill -2 $pid) && sleep 5 && (kill -15 $pgid || kill $pid) && sleep 5 && (kill -9 $pgid || kill -9 $pid) &";
186      }      }
187      # This will hang if the kill doesn't work. Nothin' to do, and it's not ok.      # This will hang if the kill doesn't work. Nothin' to do, and it's not ok.
188      catch "close -i $spawn_id";      catch "close -i $spawn_id";
# Line 212  proc local_exec { commandline inp outp t Line 215  proc local_exec { commandline inp outp t
215      }      }
216      verbose "output is $output";      verbose "output is $output";
217      if { $outp == "" } {      if { $outp == "" } {
218      return [list $status $output];          return [list $status $output];
219      } else {      } else {
220          return [list $status ""];          return [list $status ""];
221      }      }
# Line 314  proc standard_close { host } { Line 317  proc standard_close { host } {
317          }          }
318          if { $pid > 0 } {          if { $pid > 0 } {
319              verbose "doing kill, pid is $pid";              verbose "doing kill, pid is $pid";
320              # This is very, very nasty. Then again, if after did something              # This is very, very nasty. SH, instead of EXPECT, is used
321              # reasonable...              # to run this in the background since, on older CYGWINs, a
322                # strange file I/O error occures.
323              set pgid "-[join $pid { -}]";              set pgid "-[join $pid { -}]";
324              exec sh -c "exec > /dev/null 2>&1 && (kill -2 $pgid || kill -2 $pid) && sleep 5 && (kill $pgid || kill $pid) && sleep 5 && (kill -9 $pgid || kill -9 $pid)" &;              exec sh -c "exec > /dev/null 2>&1 && (kill -2 $pgid || kill -2 $pid) && sleep 5 && (kill $pgid || kill $pid) && sleep 5 && (kill -9 $pgid || kill -9 $pid) &";
325          }          }
326          verbose "pid is $pid";          verbose "pid is $pid";
327          catch "close -i $shell_id";          catch "close -i $shell_id";
# Line 407  proc remote_download { dest file args } Line 411  proc remote_download { dest file args }
411  #  #
412    
413  proc standard_download {dest file destfile} {  proc standard_download {dest file destfile} {
414      return [rsh_download $dest $file $destfile];      set orig_destfile $destfile
415    
416        if [board_info $dest exists nfsdir] {
417            set destdir [board_info $dest nfsdir]
418            if [board_info $dest exists nfsroot_server] {
419                set dest [board_info $dest nfsroot_server];
420            } else {
421                set dest "";
422            }
423            set destfile "$destdir/$destfile";
424        }
425    
426        if { "$dest" != "" } {
427            set result [rsh_download $dest $file $destfile];
428            if { $result == $destfile } {
429                return $orig_destfile;
430            } else {
431                return $result;
432            }
433        }
434    
435        set result [catch "exec cp -p $file $destfile" output];
436        if [regexp "same file|are identical" $output] {
437            set result 0
438            set output ""
439        } else {
440            # try to make sure we can read it
441            # and write it (in case we copy onto it again)
442            catch {exec chmod u+rw $destfile}
443        }
444        if { $result != 0 || $output != "" } {
445            perror "remote_download to $dest of $file to $destfile: $output"
446            return "";
447        } else {
448            return $orig_destfile;
449        }
450  }  }
451    
452  proc remote_upload {dest srcfile args} {  proc remote_upload {dest srcfile args} {
# Line 429  proc remote_upload {dest srcfile args} { Line 468  proc remote_upload {dest srcfile args} {
468  }  }
469    
470  proc standard_upload { dest srcfile destfile } {  proc standard_upload { dest srcfile destfile } {
471        set orig_srcfile $srcfile
472    
473        if [board_info $dest exists nfsdir] {
474            set destdir [board_info $dest nfsdir]
475            if [board_info $dest exists nfsroot_server] {
476                set dest [board_info $dest nfsroot_server];
477            } else {
478                set dest "";
479            }
480            set srcfile "$destdir/$srcfile";
481        }
482    
483        if { "$dest" != "" } {
484            return [rsh_upload $dest $srcfile $destfile];
485        }
486    
487        set result [catch "exec cp -p $srcfile $destfile" output];
488        if [regexp "same file|are identical" $output] {
489            set result 0
490            set output ""
491        } else {
492            # try to make sure we can read it
493            # and write it (in case we copy onto it again)
494            catch {exec chmod u+rw $destfile}
495        }
496        if { $result != 0 || $output != "" } {
497            perror "remote_upload to $dest of $file to $destfile: $output"
498            return "";
499        } else {
500            return $destfile;
501        }
502    
503      return [rsh_upload $dest $srcfile $destfile];      return [rsh_upload $dest $srcfile $destfile];
504  }  }
505    
# Line 442  proc call_remote { type proc dest args } Line 513  proc call_remote { type proc dest args }
513      if [board_info $dest exists name] {      if [board_info $dest exists name] {
514          set dest [board_info $dest name];          set dest [board_info $dest name];
515      }      }
 verbose "In call_remote with $dest, $args"  
516    
517      if { $dest != "host" && $dest != "build" && $dest != "target" } {      if { $dest != "host" && $dest != "build" && $dest != "target" } {
518          if { ![board_info $dest exists name] } {          if { ![board_info $dest exists name] } {
# Line 779  proc remote_raw_spawn { dest commandline Line 849  proc remote_raw_spawn { dest commandline
849  #  #
850  # The default spawn procedure. Uses rsh to connect to $dest.  # The default spawn procedure. Uses rsh to connect to $dest.
851  #  #
852  proc standard_spawn { dest commandline args } {  proc standard_spawn { dest commandline } {
853      global board_info      global board_info
854    
855      if ![board_info $dest exists rsh_prog] {      if ![board_info $dest exists rsh_prog] {
# Line 795  proc standard_spawn { dest commandline a Line 865  proc standard_spawn { dest commandline a
865      if ![board_info $dest exists username] {      if ![board_info $dest exists username] {
866          set rsh_useropts ""          set rsh_useropts ""
867      } else {      } else {
868          set rsh_useropts "-l [board_info $dest username]"          set rsh_useropts "-l $username"
869      }      }
870    
871      if [board_info $dest exists hostname] {      if [board_info $dest exists hostname] {
# Line 804  proc standard_spawn { dest commandline a Line 874  proc standard_spawn { dest commandline a
874          set remote $dest;          set remote $dest;
875      }      }
876    
877  #    spawn $RSH $rsh_useropts $remote $commandline;      spawn $RSH $rsh_useropts $remote $commandline;
     spawn "/bin/sh" "-c" "$RSH $rsh_useropts $remote \"$commandline\"";  
878      set board_info($dest,fileid) $spawn_id;      set board_info($dest,fileid) $spawn_id;
879      return $spawn_id;      return $spawn_id;
880  }  }
# Line 1068  proc standard_wait { dest timeout } { Line 1137  proc standard_wait { dest timeout } {
1137    
1138  proc check_for_board_status  { variable } {  proc check_for_board_status  { variable } {
1139      upvar $variable output;      upvar $variable output;
1140        
1141      # If all programs of this board have a wrapper that always outputs a      # If all programs of this board have a wrapper that always outputs a
1142      # status message, then the absence of it means that the program      # status message, then the absence of it means that the program
1143      # crashed, regardless of status found elsewhere (e.g. simulator exit      # crashed, regardless of status found elsewhere (e.g. simulator exit
# Line 1083  proc check_for_board_status  { variable Line 1152  proc check_for_board_status  { variable
1152          regsub "^.*\\*\\*\\* EXIT code " $output "" result;          regsub "^.*\\*\\*\\* EXIT code " $output "" result;
1153          regsub "\[\r\n\].*$" $result "" result;          regsub "\[\r\n\].*$" $result "" result;
1154          regsub -all "(^|\[\r\n\]|\r\n)\\*\\*\\* EXIT code \[^\r\n\]*(\[\r\n\]\[\r\n\]?|$)" $output "" output;          regsub -all "(^|\[\r\n\]|\r\n)\\*\\*\\* EXIT code \[^\r\n\]*(\[\r\n\]\[\r\n\]?|$)" $output "" output;
 ###     regsub -all "(^|\r?\n)\\*\\*\\* EXIT code \[^\r\n\]*(\r?\n|$)" $output "" output;  
1155          regsub "^\[^0-9\]*" $result "" result          regsub "^\[^0-9\]*" $result "" result
1156          regsub "\[^0-9\]*$" $result "" result          regsub "\[^0-9\]*$" $result "" result
1157          verbose "got board status $result" 3          verbose "got board status $result" 3

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26