Hi,

here the patch which addresses the comments made on this list and no
irc.  It changes the layout where the testcase are downloaded on the
remote target by introducing a new directory under /tmp, where the
programs are downloaded and executed. (i.e /tmp/test_name.PID =>
/tmp/runtest.PID/test_name and execution => cd /tmp/runtest.PID/ ;
/tmp/runtest.PID/test_name).

Tested on a full cross validaiton of GCC without regressions.

Rq: The behavior of the standard routines is not changed, only the
name remotefile is modifed.

Cheers,
Yvan

2016-04-03  Yvan Roux  <yvan.r...@linaro.org>

        * config/unix.exp (unix_load): Delegate remote directory handling to
        remote_download.
        * lib/remote.exp (remnote_download): Create a remote directory (in a
        new global remotedir) if needed and handle it.
        (remote_exec): Execute program inside remotedir when it exists.
        (remote_close): Remove remotedir when it exists.
        (standard_load): Delegate remote directory handling to
        remote_download.

On 15 March 2016 at 05:34, Ben Elliston <b...@air.net.au> wrote:
> Your proposed solution seems fine. Please send a fully documented
> patch and I'll review it.
>
> Cheers, Ben
diff --git a/config/unix.exp b/config/unix.exp
index c9d80dc..428f741 100644
--- a/config/unix.exp
+++ b/config/unix.exp
@@ -97,7 +97,7 @@ proc unix_load { dest prog args } {
            setenv SHLIB_PATH $orig_ld_library_path
        }
     } else {
-       set remotefile "/tmp/[file tail $prog].[pid]"
+       set remotefile [file tail $prog]
        set remotefile [remote_download $dest $prog $remotefile]
        if { $remotefile == "" } {
            verbose -log "Download of $prog to [board_info $dest name] failed." 
3
diff --git a/lib/remote.exp b/lib/remote.exp
index 043368b..b5f6006 100644
--- a/lib/remote.exp
+++ b/lib/remote.exp
@@ -277,6 +277,8 @@ proc local_exec { commandline inp outp timeout } {
 # redirected).
 #
 proc remote_exec { hostname program args } {
+    global remotedir
+
     if { [llength $args] > 0 } {
        set pargs [lindex $args 0]
     } else {
@@ -312,6 +314,9 @@ proc remote_exec { hostname program args } {
     if { ![is_remote $hostname] } {
        set result [local_exec "$program $pargs" $inp $outp $timeout]
     } else {
+        if { [info exists remotedir] } {
+            set program "cd $remotedir ; $program"
+        }
        set result [call_remote "" exec $hostname $program $pargs $inp $outp]
     }
 
@@ -329,6 +334,11 @@ proc standard_exec { hostname args } {
 #            or target, host or build.
 #
 proc remote_close { host } {
+    global remotedir
+
+    if {[info exists remotedir]} {
+        remote_exec $host "/bin/rm" "-rf $remotedir"
+    }
     while { 1 } {
        set result [call_remote "" close "$host"]
        if { [remote_pop_conn $host] != "pass" } {
@@ -422,6 +432,8 @@ proc standard_reboot { host } {
 #
 
 proc remote_download { dest file args } {
+    global remotedir
+
     if { [llength $args] > 0 } {
        set destfile [lindex $args 0]
     } else {
@@ -449,6 +461,16 @@ proc remote_download { dest file args } {
            }
        }
     }
+    if { ![info exists remotedir] } {
+        set rtmp "/tmp/runtest.[pid]"
+        set status [remote_exec $dest mkdir "-p $rtmp"]
+        if { [lindex $status 0] != 0 } {
+            verbose -log "Couldn't create remote directory $rtmp on $dest" 3
+            return [list "unresolved" ""]
+        }
+        set remotedir $rtmp
+    }
+    set destfile "$remotedir/$destfile"
 
     return [call_remote "" download $dest $file $destfile]
 }
@@ -1049,7 +1071,7 @@ proc standard_load { dest prog args } {
     }
 
     if {[is_remote $dest]} {
-       set remotefile "/tmp/[file tail $prog].[pid]"
+       set remotefile [file tail $prog]
        set remotefile [remote_download $dest $prog $remotefile]
        if { $remotefile == "" } {
            verbose -log "Download of $prog to [board_info $dest name] failed." 
3
_______________________________________________
DejaGnu mailing list
DejaGnu@gnu.org
https://lists.gnu.org/mailman/listinfo/dejagnu

Reply via email to