diff mbox

[1/3] Extend cleanfiles for multiple hosts

Message ID 1408075184-25947-2-git-send-email-yao@codesourcery.com
State New
Headers show

Commit Message

Yao Qi Aug. 15, 2014, 3:59 a.m. UTC
Nowadays, GDB testsuite has a list cleanfiles which includes files copies
to target.  This patch is to extend it to an array, in which the key is
the host name, and the value is a list of file names.  In this way,
cleanfiles can be used to keep track of files copied to multiple hosts.
No functionality is changed.

gdb/testsuite:

2014-08-14  Yao Qi  <yao@codesourcery.com>

	* lib/gdb.exp (gdb_download): Find the value in 'cleanfiles' by
	key 'target' and append $destname to it.
	(default_gdb_init): Clear array cleanfiles.
	(gdb_finish): Remove all files in 'cleanfiles' and clear it.
---
 gdb/testsuite/lib/gdb.exp | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 92069c9..e175833 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3537,7 +3537,7 @@  proc gdb_download { filename } {
     global cleanfiles
 
     set destname [remote_download target $filename]
-    lappend cleanfiles $destname
+    lappend cleanfiles(target) $destname
     return $destname
 }
 
@@ -3595,7 +3595,7 @@  proc default_gdb_init { test_file_name } {
     global cleanfiles
     global pf_prefix
     
-    set cleanfiles {}
+    array unset cleanfiles
 
     gdb_clear_suppressed
 
@@ -3862,10 +3862,15 @@  proc gdb_finish { } {
     # Exit first, so that the files are no longer in use.
     gdb_exit
 
-    if { [llength $cleanfiles] > 0 } {
-	eval remote_file target delete $cleanfiles
-	set cleanfiles {}
+    # CLEANFILES is an array, in which the key is host name, such as
+    # 'target' or 'host' etc, and the value is a list of files copied
+    # to the machine represented by the key.
+    foreach dest [array names cleanfiles] {
+	foreach filename $cleanfiles($dest) {
+	    eval remote_file $dest delete $filename
+	}
     }
+    array unset cleanfiles
 
     # Unblock write access to the banned variables.  Dejagnu typically
     # resets some of them between testcases.