From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22888 invoked by alias); 15 Jun 2012 19:00:30 -0000 Received: (qmail 22878 invoked by uid 22791); 15 Jun 2012 19:00:28 -0000 X-SWARE-Spam-Status: No, hits=-7.4 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 15 Jun 2012 19:00:12 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q5FJ00Gf005272 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 15 Jun 2012 15:00:00 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q5FIxwqO008939; Fri, 15 Jun 2012 14:59:59 -0400 Message-ID: <4FDB862E.60404@redhat.com> Date: Fri, 15 Jun 2012 19:00:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: Yao Qi CC: gdb-patches@sourceware.org Subject: Re: [PATCH 1/4] New test for removing socket file in gdb.trace/strace.exp. References: <1339246002-1987-1-git-send-email-yao@codesourcery.com> <1339246002-1987-2-git-send-email-yao@codesourcery.com> <4FD75749.3040305@redhat.com> <201206142239.28343.yao@codesourcery.com> In-Reply-To: <201206142239.28343.yao@codesourcery.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-06/txt/msg00522.txt.bz2 On 06/14/2012 03:39 PM, Yao Qi wrote: > On Tuesday 12 June 2012 22:50:49 Pedro Alves wrote: >>> + set test "socket file exists" >>> + set socket_file "/tmp/gdb_ust${pid}" >>> + if { [file exists $socket_file] } { >>> + pass $test >>> + } else { >>> + fail $test >>> + } >> >> This won't work with remote host testing. This file is really a >> file on the target. Why not use "remote_file target exists" ? >> > > Yes, we should use "remote_file XXX exits", however, I find "remote_file XXX > exists" always return 0 for socket file because it uses "[ -f $file ]" to check > whether file exists. I work around this limitation in this way, > Bummer. :-( > set exists "" > if [is_remote target] { > set status [remote_exec target "sh -c \"exit `\\\[ -S $socket_file `\""] > set exists [expr [lindex $status 0] == 0] > } else { > set exists [file exists $socket_file] > } > > b.t.w, the quote on tcl and bash makes crazy :) :-) In general, there are plenty of targets where we can't assume a posix shell on the target. But in this case, since this functionality is implemented on GNU/Linux, we can go with it. I think -S is a bash extension, but again, it may be okay in this case. I tried ksh, and dash, and both accept it. I don't understand how the else branch works for you with remote host native testing, as you're checking for a file on the build machine, not the host (where GDB runs) (unless you're sharing /tmp between build and host machines, but you're probably not.) Is there anything preventing using "remote_exec target" bits always, getting rid of the else branch? > >>> + >>> + send_gdb "${action}\n" >>> + gdb_expect { >>> + -re "A debugging session is active.\r\n.*\r\nQuit anyway\\? \\(y or >>> n\\) $" { + send_gdb "y\n" >>> + } >>> + -re "Detaching .*, process .*$" { >>> + } >>> + -re "Continuing.*$" { >>> + } >>> + } >> >> gdb_test_multiple ? > > When I tried gdb_test_multiple, I'll get an extra fail, so I use > send_gdb/gdb_expect, > > FAIL: gdb.trace/strace.exp: remove_socket_after_quit: quit (got interactive prompt) > > This new test is tested on native on local host, native-gdbserver, and native > on remote host. > I saw some problems when running test on remote host. They are > not related to this patch series, so I'd like to defer them to follow up > fix later. Thanks, that mode tends to rot a bit. > > gdb/testsuite: > > 2012-06-14 Yao Qi > > PR gdb/14161. > * gdb.trace/strace.exp (strace_remove_socket): New proc to test > the socket file is removed. The uses of the new function should be mentioned as well. > +proc strace_remove_socket { action } { > + sleep 5 We have 3 calls to this function, adding up to 15 seconds. We could do things a bit differently to try to avoid always sleeping, or sleeping so much. For instance, with something like this pseudo code: detach $exists=true for i in 0..4 { if ! socket exists $exists=false break sleep 1 } if $exists fail $test else pass $test IOW, check if the socket exists or not immediately after detaching. Only sleep if we find it still exists. With luck, expect will be slow enough, and we'll find the socket is gone on the first iteration, avoiding the sleep. If not, we'll wait one second, then re-check, etc. -- Pedro Alves