dejagnu
[Top][All Lists]
Advanced

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

DejaGnu: support nfsdir and nfsroot_server


From: Alexandre Oliva
Subject: DejaGnu: support nfsdir and nfsroot_server
Date: 05 Mar 2003 02:34:52 -0300
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

When a remote board supports rsh but not rcp, and it mounts its root
filesystem from the test host, or from another host that supports rcp,
we can take advantage of file sharing to upload and download files
to/from the board.  This patch implements this feature.  Ok to
install in the sources.redhat.com repository?

Index: dejagnu/ChangeLog
from  Alexandre Oliva  <address@hidden>

        * lib/remote.exp (standard_download, standard_upload): Support
        nfsdir and nfsroot_server.

Index: dejagnu/lib/remote.exp
===================================================================
RCS file: /cvs/src/src/dejagnu/lib/remote.exp,v
retrieving revision 1.5
diff -u -p -r1.5 remote.exp
--- dejagnu/lib/remote.exp 21 Apr 2002 08:47:07 -0000 1.5
+++ dejagnu/lib/remote.exp 5 Mar 2003 05:27:45 -0000
@@ -1,4 +1,4 @@
-# Copyright (C) 1992 - 2001, 2002 Free Software Foundation, Inc.
+# Copyright (C) 1992 - 2001, 2002, 2003 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -411,7 +411,42 @@ proc remote_download { dest file args } 
 #
 
 proc standard_download {dest file destfile} {
-    return [rsh_download $dest $file $destfile];
+    set orig_destfile $destfile
+
+    if [board_info $dest exists nfsdir] {
+       set destdir [board_info $dest nfsdir]
+       if [board_info $dest exists nfsroot_server] {
+           set dest [board_info $dest nfsroot_server];
+       } else {
+           set dest "";
+       }
+       set destfile "$destdir/$destfile";
+    }
+
+    if { "$dest" != "" } {
+       set result [rsh_download $dest $file $destfile];
+       if { $result == $destfile } {
+           return $orig_destfile;
+       } else {
+           return $result;
+       }
+    }
+
+    set result [catch "exec cp -p $file $destfile" output];
+    if [regexp "same file|are identical" $output] {
+       set result 0
+       set output ""
+    } else {
+       # try to make sure we can read it
+       # and write it (in case we copy onto it again)
+       catch {exec chmod u+rw $destfile}
+    }
+    if { $result != 0 || $output != "" } {
+       perror "remote_download to $dest of $file to $destfile: $output"
+       return "";
+    } else {
+       return $orig_destfile;
+    }
 }
 
 proc remote_upload {dest srcfile args} {
@@ -433,6 +468,38 @@ proc remote_upload {dest srcfile args} {
 }
 
 proc standard_upload { dest srcfile destfile } {
+    set orig_srcfile $srcfile
+
+    if [board_info $dest exists nfsdir] {
+       set destdir [board_info $dest nfsdir]
+       if [board_info $dest exists nfsroot_server] {
+           set dest [board_info $dest nfsroot_server];
+       } else {
+           set dest "";
+       }
+       set srcfile "$destdir/$srcfile";
+    }
+
+    if { "$dest" != "" } {
+       return [rsh_upload $dest $srcfile $destfile];
+    }
+
+    set result [catch "exec cp -p $srcfile $destfile" output];
+    if [regexp "same file|are identical" $output] {
+       set result 0
+       set output ""
+    } else {
+       # try to make sure we can read it
+       # and write it (in case we copy onto it again)
+       catch {exec chmod u+rw $destfile}
+    }
+    if { $result != 0 || $output != "" } {
+       perror "remote_upload to $dest of $file to $destfile: $output"
+       return "";
+    } else {
+       return $destfile;
+    }
+
     return [rsh_upload $dest $srcfile $destfile];
 }
 
-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 address@hidden, gcc.gnu.org}
CS PhD student at IC-Unicamp        address@hidden, gnu.org}
Free Software Evangelist                Professional serial bug killer

reply via email to

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