[OBV] Overwrite ${board}_file in local-remote-host

Message ID 1399965128-5603-1-git-send-email-yao@codesourcery.com
State Committed
Headers

Commit Message

Yao Qi May 13, 2014, 7:12 a.m. UTC
  After I run test like this,

 $ make check RUNTESTFLAGS='--host_board=local-remote-host dw2-basic.exp'

gdb.dwarf2/file1.txt in source tree was removed.  In some gdb.dwarf2/*.exp,
file1.txt is copied to host and then removed at the end.  However, in
local-remote-host-notty.exp, ${board}_download doesn't copy the file but
return the absolute path of the src file.  'remote_file host delete' at
the end will remove the file in source tree.

This patch is to overwrite ${board}_file, and specially make "delete"
option do nothing.  This approach is used in gdbserver-base.exp and
remote-stdio-gdbserver.exp too.  It is obvious.  I'll commit it in two
days if there are no objections.

gdb/testsuite:

2014-05-13  Yao Qi  <yao@codesourcery.com>

	* boards/local-remote-host-notty.exp (${board}_file): New proc.
---
 gdb/testsuite/boards/local-remote-host-notty.exp | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

Pedro Alves May 13, 2014, 6:19 p.m. UTC | #1
On 05/13/14 08:12, Yao Qi wrote:
> After I run test like this,
> 
>  $ make check RUNTESTFLAGS='--host_board=local-remote-host dw2-basic.exp'
> 
> gdb.dwarf2/file1.txt in source tree was removed.  In some gdb.dwarf2/*.exp,
> file1.txt is copied to host and then removed at the end.  However, in
> local-remote-host-notty.exp, ${board}_download doesn't copy the file but
> return the absolute path of the src file.  'remote_file host delete' at
> the end will remove the file in source tree.
> 
> This patch is to overwrite ${board}_file, and specially make "delete"
> option do nothing.  This approach is used in gdbserver-base.exp and
> remote-stdio-gdbserver.exp too.  It is obvious.  I'll commit it in two
> days if there are no objections.

Thanks.  I agree it's obvious, knowing we already do that in
other board files.  Go ahead and push.
  
Yao Qi May 14, 2014, 7:58 a.m. UTC | #2
On 05/14/2014 02:19 AM, Pedro Alves wrote:
> Thanks.  I agree it's obvious, knowing we already do that in
> other board files.  Go ahead and push.

Thanks, Pedro.  Patch is pushed in.
  
Doug Evans May 14, 2014, 3:24 p.m. UTC | #3
On Wed, May 14, 2014 at 12:58 AM, Yao Qi <yao@codesourcery.com> wrote:
> On 05/14/2014 02:19 AM, Pedro Alves wrote:
>> Thanks.  I agree it's obvious, knowing we already do that in
>> other board files.  Go ahead and push.
>
> Thanks, Pedro.  Patch is pushed in.

Hi.

There's no comments in the code explaining Why Things Are The Way They Are.
It's not obvious to me that wanting to delete a file should
necessarily always be a nop.
I can imagine writing a test where I need it to not be a nop.
[I realize gdbserver-base.exp has the same problem, and I may have even
been the one that originally put it there (this file was created to contain
some common parts of the native-*.exp files).
btw, gdbserver-base.exp needs to be renamed to native-gdbserver-base.exp,
hardwiring delete to be a nop is only for native gdbserver.]

Looking at gdb_remote_download I see gdb_download does this differently.
It appends the file to cleanfiles which is a list of files to be
deleted (on the target) when the test ends.
So now we have two different solutions to similar problems: cleaning
up after a test.
If you use gdb_remote_download you have to remember to delete it at
the end and if you use gdb_download you don't.
[I realize gdb_download is for the target only.]
Maybe we need host_cleanfiles.

I remember some tests solving this problem by giving the downloaded
file a different name.
So that's another way in which we now have two different solutions to
the same problem.
  

Patch

diff --git a/gdb/testsuite/boards/local-remote-host-notty.exp b/gdb/testsuite/boards/local-remote-host-notty.exp
index 6ff8f18..dd3ee5a 100644
--- a/gdb/testsuite/boards/local-remote-host-notty.exp
+++ b/gdb/testsuite/boards/local-remote-host-notty.exp
@@ -33,6 +33,13 @@  set_board_info rsh_prog /usr/bin/ssh
 set_board_info rcp_prog /usr/bin/scp
 set_board_info file_transfer "rsh"
 
+proc ${board}_file { dest op args } {
+    if { $op == "delete" } {
+	return 0
+    }
+    return [eval [list standard_file $dest $op] $args]
+}
+
 proc ${board}_download { board src dest } {
 
     # If file name is a relative, convert it to absolute, otherwise file can't