This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Make gdb.server/connect-with-no-symbol-file.exp more robust


Yao noticed failing tests with the remote-gdbserver-on-localhost board file.

Investigating further i noticed the test, as is,  may delete the original symbol
files, causing failures to occur.

I went ahead and adjusted the test so it properly restores the state of the
files with every iteration and also moved the required commands to functions.

Last, i adjusted the "detach" pattern because extended remote does not
completely disconnect from GDB, so it doesn't show the last piece of text.

I get full passes with the following board files:

native-gdbserver.exp
native-extended-gdbserver.exp
remote-gdbserver-on-localhost.exp

Unfortunately i see FAIL's (4) with both stdio-based gdbserver boards because,
obviously, the launching of gdbserver and issuing of the "target remote"
command happen at the same time. Thus, no time to delete or make the symbol
file inacessible.

Any suggestions? Should we restrict this test to non-stdio boards?

gdb/testsuite/ChangeLog:

2016-04-15  Luis Machado  <lgustavo@codesourcery.com>

	gdb.server/connect-with-no-symbol-file.exp (delete_files): New
	function.
	(restore_files_from_backup): New function.
	(make_inaccessible): New function.
	(connect_no_symbol_file): Adjust detachment test pattern.
	Call helper functions.
---
 .../gdb.server/connect-with-no-symbol-file.exp     | 32 ++++++++++++++++++----
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp b/gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp
index f99e1af..6657399 100644
--- a/gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp
+++ b/gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp
@@ -33,6 +33,27 @@ if { [prepare_for_testing $testfile.exp $testfile $srcfile debug] } {
     return -1
 }
 
+# Delete FILE in both the host and the target.
+#
+proc delete_files { file } {
+  remote_file host delete $file
+  remote_file target delete $file
+}
+
+# Restore FILE in both the host and the target from FILE.bak.
+#
+proc restore_files_from_backup { file } {
+    gdb_remote_download host $file.bak $file
+    gdb_remote_download target $file.bak $file
+}
+
+# Make FILE inaccessible in both the host and the target.
+#
+proc make_inaccessible { file } {
+    remote_exec host "chmod 000 $file"
+    remote_exec target "chmod 000 $file"
+}
+
 # Test connecting GDB to GDBserver without loading a symbol file.
 #
 # SYSROOT is the desired sysroot string
@@ -45,8 +66,9 @@ proc connect_no_symbol_file { sysroot action } {
     global binfile
 
     with_test_prefix "setup" {
-	# Copy the symbol file to the target.
-	gdb_remote_download target $binfile.bak $binfile 
+	# Restore the files to the initial state.
+	delete_files $binfile
+	restore_files_from_backup $binfile
 
 	# Make sure we're disconnected, in case we're testing with an
 	# extended-remote board, therefore already connected.
@@ -70,9 +92,9 @@ proc connect_no_symbol_file { sysroot action } {
 
 	# Perform test actions to the symbol file on the target.
 	if { $action == "delete" } then {
-	  remote_file target delete $binfile
+	    delete_files $binfile
 	} elseif { $action == "permission" } {
-	  remote_spawn target "chmod 000 $binfile"
+	    make_inaccessible $binfile
 	}
        
 	# Connect to GDBserver.
@@ -82,7 +104,7 @@ proc connect_no_symbol_file { sysroot action } {
     # Check if GDB succeeded connecting to GDBserver by attempting to detach
     # from the process.
     gdb_test "detach" \
-	".*Detaching from program: , process.*Ending remote debugging.*" \
+	".*Detaching from program: , process \[0-9\]+\[^\r\n\]*.*" \
 	"connection to GDBserver succeeded"
 }
 
-- 
1.9.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]