From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id OGlzEra79me0RS0AWB0awg (envelope-from ) for ; Wed, 09 Apr 2025 14:25:58 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=US/GmDjf; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 37D3C1E0C3; Wed, 9 Apr 2025 14:25:58 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 35C891E05C for ; Wed, 9 Apr 2025 14:25:57 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A7630384584C for ; Wed, 9 Apr 2025 18:25:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A7630384584C Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=US/GmDjf Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 0D4ED385E020 for ; Wed, 9 Apr 2025 18:25:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0D4ED385E020 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0D4ED385E020 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744223123; cv=none; b=CXAKA/ueC4/yRid5o+AxhCdMvC2+QYKmyQzVRcaBvUZk+peDtLSk8LYBG63KCxRRUW+ArZO5tLIzAXQCdBZ/zp0MQZO9912f1torHW4RpgpqpWD8dMuhdJLApn+ilvqZlCDJtIZ95hBb6QK1c4QJfDdH38tsKZQzqWqXfPeWwfk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1744223123; c=relaxed/simple; bh=V8YMdRsLBgOLKL3Q3fC+8rsWK+D58SRUi1l5McY+dBs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=PZVrDr+/p+l/Tn94ydAIxY/d8P5RWKkzZ79PClK9Hdn6SfuT4rbrpg2OVRC72I+ksy9b2+kckNvoLlitLgTJTNozn4vBgmiq3iWdY/s70sPA5bsn9/uFyZzkJdTc/9k3AINugafNwyeVt7HDfKu8D2ebyLPTimLG74pmeMAJ8vI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0D4ED385E020 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744223122; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=na2SgDNjdnaBL7EP5XyiwWq/r5xm5YKVm9z+gUUOk1s=; b=US/GmDjfLWZpdppvmASZxp+ncPZW/fbgD/pa7uNoEVY6zuGCcbJhd41Qm32Uvq6KGuBweJ LinK/8oOy96245LQxvXCqi+zcdol2jnzXZrF2WN7PjPX2CVeGDQ35o3PPMDTwCZfuTOxSM /DC37Jf3Xn0/Df6iIQuLac2QMYM3Iuk= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-116-dBBmfrbrPsaJffFWjl1S9w-1; Wed, 09 Apr 2025 14:25:18 -0400 X-MC-Unique: dBBmfrbrPsaJffFWjl1S9w-1 X-Mimecast-MFC-AGG-ID: dBBmfrbrPsaJffFWjl1S9w_1744223118 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DBBE3180AF6D for ; Wed, 9 Apr 2025 18:25:17 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.96.134.159]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8D40A180B488; Wed, 9 Apr 2025 18:25:16 +0000 (UTC) From: Guinevere Larsen To: gdb-patches@sourceware.org Cc: Guinevere Larsen Subject: [PATCH] gdb/testsuite: fix gdb.base/dlmopen-ns-ids.exp racy test Date: Wed, 9 Apr 2025 15:25:10 -0300 Message-ID: <20250409182510.1629742-1-guinevere@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: hhP0yE9nsu2JwfMCurhZw_vFN5paMHa53FFaGiVzTiY_1744223118 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org The recently included gdb.base/dlmopen-ns-ids.exp test can sometimes fail the call to get_integer_valueof when trying to check the namespace ID of the fourth dlopened SO, for apparently no reason. What's happening is that the call to get_first_so_ns doesn't necessarily consume the GDB prompt, and so get_integer_valueof will see the prompt immediately and not find the value the test is looking for. To fix this, a call to gdb_test is added to the end of get_first_so_ns to consume the prompt if it wasn't consumed by the previous gdb_test_multiple call. If the namespace was found (and so ns is not -1), we can guarantee that the prompt was not consumed. I tried several other ways to solve that problem, but they each caused different problems: * using -wrap in the second block of the gdb_test_multiple resulted in every call timing out * reducing the output with a pattern on the "info shared" call and adding -wrap caused the line to not be recognized * using exp_continue caused the value of ns to be overwritten, returning the last SO_NS, instead of the first With all these problems, adding the gdb_test call seemed the least fragile option. --- gdb/testsuite/gdb.base/dlmopen-ns-ids.exp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp index 03b7a527af5..5c65162d98f 100644 --- a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp +++ b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp @@ -45,7 +45,7 @@ proc get_first_so_ns {} { -re "From\\s+To\\s+\(NS\\s+\)?Syms\\s+Read\\s+Shared Object Library\r\n" { exp_continue } - -re "^$::hex\\s+$::hex\\s+\\\[\\\[($::decimal)\\\]\\\]\\s+\[^\r\n]+$::binfile_lib.*" { + -re "^$::hex\\s+$::hex\\s+\\\[\\\[($::decimal)\\\]\\\]\\s+\[^\r\n]+$::binfile_lib\r\n" { set ns $expect_out(1,string) } -re "^$::gdb_prompt $" { @@ -54,6 +54,14 @@ proc get_first_so_ns {} { exp_continue } } + # Clear the prompt from the previous test, if it was not consumed. + # This can't be done in the previous test because we need to leave on + # the first occurrence of the library, otherwise we'll overwrite the + # namespace found, and just adding gdb_prompt to the end of the success + # case caused several timeouts. + if {$ns != -1} { + gdb_test -nopass "" ".*" + } return $ns } base-commit: d8c3e4901650e35ddf5083f693b8a21b9d24fcc6 -- 2.49.0