From patchwork Fri Apr 15 18:55:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 11767 Received: (qmail 43487 invoked by alias); 15 Apr 2016 18:55:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 43462 invoked by uid 89); 15 Apr 2016 18:55:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:3630 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 15 Apr 2016 18:55:32 +0000 Received: from svr-orw-fem-03.mgc.mentorg.com ([147.34.97.39]) by relay1.mentorg.com with esmtp id 1ar8tu-0001R2-9k from Luis_Gustavo@mentor.com ; Fri, 15 Apr 2016 11:55:30 -0700 Received: from opsys.alm.mentorg.com (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.3.224.2; Fri, 15 Apr 2016 11:55:29 -0700 From: Luis Machado To: , Subject: [PATCH] Make gdb.server/connect-with-no-symbol-file.exp more robust Date: Fri, 15 Apr 2016 13:55:22 -0500 Message-ID: <1460746522-6703-1-git-send-email-lgustavo@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes 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 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" }