Re: [RFA] fix remote testing I/O conflicts

Yvan Roux <[email protected]>
Newsgroups gmane.comp.sysutils.dejagnu.general
Message-ID <CAD57uCei7PrbNZtFUjN7bv+T55mkKnNG613k1H=H8sjqVgLP4A@mail.gmail.com>
Hi,

On 4 April 2016 at 10:21, Yvan Roux <[email protected]> wrote:
> Hi Ben,
>
> On 4 April 2016 at 10:16, Ben Elliston <[email protected]> wrote:
>> Hi Yvan,
>>
>>>         * 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.
>>
>> remotedir shouldn't be a global variabl. It needs to be a proper board
>> setting -- please, no more globals! :-)
>
> Oh ok ... it was a board setting in my first patch, maybe I
> misunderstood the comments ;)
>
>> Can you please fix the patch to do this?  Also, you need to make sure
>> the documentation is updated with the new board setting so that people
>> don't need to read the DejaGnu code to discover it.
>
> Ok, sure.

Here is the new version of the patch (GCC cross validation is OK).

Cheers,
Yvan

 2016-04-06  Yvan Roux  <[email protected]>

        * doc/dejagnu.texi (Board File Values): Document new remotedir field.
        * config/unix.exp (unix_load): Handle remote directory in board field.
        (remotedir): Set board info field.
        * lib/remote.exp (remnote_download): Create a remote directory if
        needed and use it.
        (remote_exec): Execute program inside remotedir when it exists.
        (standard_load): Set remotedir board field if not present.

_______________________________________________
DejaGnu mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/dejagnu
remote-validation-fix.diff (text/plain, 3 KB)
diff --git a/config/unix.exp b/config/unix.exp
index c9d80dc..6a0ff72 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
@@ -145,4 +145,5 @@ proc unix_load { dest prog args } {
     return [list $result $output]
 }
 
+set_board_info remotedir "/tmp/runtest.[pid]"
 set_board_info protocol  "unix"
diff --git a/doc/dejagnu.texi b/doc/dejagnu.texi
index 35a0af4..a455ce6 100644
--- a/doc/dejagnu.texi
+++ b/doc/dejagnu.texi
@@ -2016,6 +2016,8 @@ objcopy@tab $tempfil@tab The path to the @code{objcopy} program.
 support_libs@tab "$@{prefix_dir@}/i386-coff/"@tab Support libraries needed for cross compiling.
 @item
 addl_link_flags@tab "-N"@tab Additional link flags, rarely used.
+@item
+remotedir@tab "/tmp/runtest.[pid]"@tab Directory on the remote target in which executables are downloaded and executed.
 @end multitable
 
 These fields are used by the GCC and GDB tests, and are mostly
diff --git a/lib/remote.exp b/lib/remote.exp
index 043368b..5184ecb 100644
--- a/lib/remote.exp
+++ b/lib/remote.exp
@@ -312,6 +312,10 @@ proc remote_exec { hostname program args } {
     if { ![is_remote $hostname] } {
 	set result [local_exec "$program $pargs" $inp $outp $timeout]
     } else {
+        if { [board_info $hostname exists remotedir] } {
+            set remotedir [board_info $hostname remotedir]
+            set program "\[ -d $remotedir \] && cd $remotedir ; $program"
+        }
 	set result [call_remote "" exec $hostname $program $pargs $inp $outp]
     }
 
@@ -449,6 +453,15 @@ proc remote_download { dest file args } {
 	    }
 	}
     }
+    if { [board_info $dest exists remotedir] } {
+        set remotedir [board_info $dest remotedir]
+        set status [remote_exec $dest mkdir "-p $remotedir"]
+        if { [lindex $status 0] != 0 } {
+            perror "Couldn't create remote directory $remotedir on $dest"
+           return ""
+        }
+        set destfile "$remotedir/$destfile"
+    }
 
     return [call_remote "" download $dest $file $destfile]
 }
@@ -1029,6 +1042,8 @@ proc remote_raw_load { dest prog args } {
 # remote_download and remote_exec to load and execute the program.
 #
 proc standard_load { dest prog args } {
+    global board_info
+
     if { [llength $args] > 0 } {
 	set pargs [lindex $args 0]
     } else {
@@ -1049,7 +1064,10 @@ proc standard_load { dest prog args } {
     }
 
     if {[is_remote $dest]} {
-	set remotefile "/tmp/[file tail $prog].[pid]"
+        if {![board_info $dest exists remotedir]} {
+            set board_info($dest,remotedir) "/tmp/runtest.[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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.