From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8700 invoked by alias); 6 Jul 2011 12:10:20 -0000 Received: (qmail 8677 invoked by uid 22791); 6 Jul 2011 12:10:14 -0000 X-SWARE-Spam-Status: No, hits=-6.9 required=5.0 tests=AWL,BAYES_00,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; Wed, 06 Jul 2011 12:09:38 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p66C9O5x017159 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 6 Jul 2011 08:09:24 -0400 Received: from dhcp-25-89.brq.redhat.com (vpn-8-84.rdu.redhat.com [10.11.8.84]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p66C9NAw007173; Wed, 6 Jul 2011 08:09:23 -0400 Message-ID: <4E145072.4030704@redhat.com> Date: Wed, 06 Jul 2011 14:36:00 -0000 From: Marek Polacek User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100827 Red Hat Thunderbird/3.1.3 MIME-Version: 1.0 To: Joel Brobecker CC: "gdb-patches@sourceware.org" Subject: Re: [PATCH] gdb.python/py-evthreads.exp: fix racy test (PR testsuite/12649) References: <4E09E2C1.2020909@redhat.com> <20110628155107.GL20676@adacore.com> In-Reply-To: <20110628155107.GL20676@adacore.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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: 2011-07/txt/msg00187.txt.bz2 On 06/28/2011 05:51 PM, Joel Brobecker wrote: > I'm also surprised to see some uses of gdb_expect in gdb.python. > I wonder if we could replace them with uses of gdb_test_multiple > (that would be a separate patch)... Hmm, after a few days of struggling with converting gdb_expect to gdb_test_multiple, I don't think that's The Right Thing anymore. The issue is that with send_gdb+gdb_expect we always get the same sequence--e.g., at the "next" test case, we get: next^M event type: continue^M thread num: 1^M [New Thread 0x7ffff7fe5710 (LWP 1364)]^M event type: continue^M thread num: 1^M 47 pthread_create (&thread3_id, NULL, thread3, NULL);^M event type: stop^M event type: stop^M (gdb) ^M Breakpoint 2, thread2 (d=0x0) at ./gdb.python/py-evthreads.c:39^M 39 int count2 = 0;^M event type: stop^M event type: stop^M stop reason: breakpoint^M breakpoint number: 2^M thread num: 2Quitting ... However, with gdb_test_multiple, we sometimes get: next^M event type: continue^M thread num: 1^M [New Thread 0x7ffff7fe5710 (LWP 31327)]^M event type: continue^M thread num: 1^M ^M Breakpoint 2, thread2 (d=0x0) at ./gdb.python/py-evthreads.c:39^M 39 int count2 = 0;^M event type: stop^M event type: stop^M stop reason: breakpointQuitting ... and some other time (and this fails): next^M event type: continue^M thread num: 1^M [New Thread 0x7ffff7fe5710 (LWP 31212)]^M event type: continue^M thread num: 1^M 47 pthread_create (&thread3_id, NULL, thread3, NULL);^M event type: stop^M event type: stop^M (gdb) FAIL: gdb.python/py-evthreads.exp: reached breakpoint 2 Quitting ... I don't understand why the gdb_test_multiple is non-deterministics :(. I thus propose this simple patch to avoid race (basically the same as before, just one extra space more). At least, for now. Tested with read{,1}. OK to commit? Thanks. 2011-07-06 Marek Polacek * gdb.python/py-evthreads.exp: Fix race by adding an anchor to match the whole output. --- gdb/gdb/testsuite/gdb.python/py-evthreads.exp.mp 2011-06-22 15:14:07.869452151 +0200 +++ gdb/gdb/testsuite/gdb.python/py-evthreads.exp 2011-07-06 13:57:08.651591506 +0200 @@ -86,7 +86,7 @@ gdb_expect { send_gdb "continue&\n" gdb_expect { -re ".*event type: continue.* -.*thread num: 1.*" { +.*thread num: 1.*\r\n$gdb_prompt " { pass "continue thread 1" } timeout {