From patchwork Thu Jan 9 23:04:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 37278 Received: (qmail 47145 invoked by alias); 9 Jan 2020 23:04:55 -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 46361 invoked by uid 89); 9 Jan 2020 23:04:54 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=H*MI:andrew, H*m:andrew X-HELO: mail-wr1-f48.google.com Received: from mail-wr1-f48.google.com (HELO mail-wr1-f48.google.com) (209.85.221.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 09 Jan 2020 23:04:53 +0000 Received: by mail-wr1-f48.google.com with SMTP id q6so9188365wro.9 for ; Thu, 09 Jan 2020 15:04:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id; bh=uUzzxx7+Am9UeUJ1wSNLqS9lHbyiuIOW5HIXNm0qGwM=; b=aUlzMTQLJ4JXBzVlgLH6OVWA7nyZCzUJLsPySb88DimNI6q5hCQNXpcX0LFGBzGwgx ISMwSeYMEYPFwaXl9LrwWFjOq+4cGreUmSva0rX1iaMgc9942IXFw3v0ai77bC3Ys1ey GAbNfq6BtK5uGS9RHWIkjWz4VTBqcCv3IJZ8OooUlZxwnGUu+ZTLcJHzK5oGZgpOTOTc kRFr2yx9sYcjErsa9L78ZbYkk+x3AND18rQjEH1m3tEYoUpd4NIviO/hwxogMPQHEepT mxY/3CIFIvphvSHtOit8tlKedIX9jKU+MCYPC0D/5kBDBQzx7oJZf7VTvb/sKDKJTdnw 2czw== Return-Path: Received: from localhost (host86-186-80-236.range86-186.btcentralplus.com. [86.186.80.236]) by smtp.gmail.com with ESMTPSA id q19sm97635wmc.12.2020.01.09.15.04.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Jan 2020 15:04:50 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PUSHED] gdb/testsuite: Fix race condition in gdb.base/skip.exp Date: Thu, 9 Jan 2020 23:04:47 +0000 Message-Id: <20200109230447.17634-1-andrew.burgess@embecosm.com> X-IsSubscribed: yes In this commit: commit 5024637fac653914d471808288dc3221bc7ec089 Date: Sun Dec 15 11:05:47 2019 +0100 Fix skip.exp test failure observed with gcc-9.2.0 A race condition was introduced into the gdb.base/skip.exp test when this line: gdb_test "step" "foo \\(\\) at.*" "step 3" Was changed to this: gdb_test "step" "foo \\(\\) at.*" "step 3" "main \\(\\) at .*" "step" Before the above change we expected GDB to behave like this: (gdb) step foo () at /path/to/gdb/testsuite/gdb.base/skip.c:42 42 return 0; (gdb) However, when the test is compiled with GCC 9.2.0 we get a different behaviour, and so we need a second 'step', like this: (gdb) step main () at /path/to/gdb.base/skip.c:32 32 x = baz ((bar (), foo ())); (gdb) step foo () at /path/to/gdb/testsuite/gdb.base/skip.c:42 42 return 0; (gdb) Now the change to the test matches against 'main () at .*', however if GDB or expect is being slow then we might only get to see output like this: (gdb) step main () at /path/to/g This will happily match the question pattern, so we send 'step' to GDB again. Now GDB continues to produce output which expect accepts, we now see this: b.base/skip.c:32 32 x = baz ((bar (), foo ())); (gdb) This has carried on from where the previous block of output left off. This doesn't match the final pattern 'foo \\(\\) at.*', but it does match the prompt pattern that gdb_test_multiple adds, and so we report the test as failing. The solution is to simply ensure that the question consumes everything up to, and including the prompt. This ensures that the prompt can't then match the failure case. The new test line becomes: gdb_test "step" "foo \\(\\) at.*" "step 3" \ "main \\(\\) at .*\r\n$gdb_prompt " "step" gdb/testsuite/ChangeLog: * gdb.base/skip.exp: Fix race condition in test. Change-Id: I9f0b0b52ef1b4f980bfaa8fe405ff06d520f3482 --- gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.base/skip.exp | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gdb/testsuite/gdb.base/skip.exp b/gdb/testsuite/gdb.base/skip.exp index d7dd3cedbec..513c9fcc82e 100644 --- a/gdb/testsuite/gdb.base/skip.exp +++ b/gdb/testsuite/gdb.base/skip.exp @@ -144,7 +144,8 @@ with_test_prefix "step after disabling 3" { gdb_test "step" ".*" "step 2"; # Return from bar() # With gcc 9.2.0 we jump once back to main before entering foo here. # If that happens try to step a second time. - gdb_test "step" "foo \\(\\) at.*" "step 3" "main \\(\\) at .*" "step" + gdb_test "step" "foo \\(\\) at.*" "step 3" \ + "main \\(\\) at .*\r\n$gdb_prompt " "step" gdb_test "step" ".*" "step 4"; # Return from foo() gdb_test "step" "main \\(\\) at.*" "step 5" } @@ -265,7 +266,8 @@ with_test_prefix "step using -fu for baz" { gdb_test "step" ".*" "step 2"; # Return from bar() # With gcc 9.2.0 we jump once back to main before entering foo here. # If that happens try to step a second time. - gdb_test "step" "foo \\(\\) at.*" "step 3" "main \\(\\) at.*" "step" + gdb_test "step" "foo \\(\\) at.*" "step 3" \ + "main \\(\\) at .*\r\n$gdb_prompt " "step" gdb_test "step" ".*" "step 4"; # Return from foo() gdb_test "step" "main \\(\\) at.*" "step 5" } @@ -282,7 +284,8 @@ with_test_prefix "step using -rfu for baz" { gdb_test "step" ".*" "step 2"; # Return from bar() # With gcc 9.2.0 we jump once back to main before entering foo here. # If that happens try to step a second time. - gdb_test "step" "foo \\(\\) at.*" "step 3" "main \\(\\) at.*" "step" + gdb_test "step" "foo \\(\\) at.*" "step 3" \ + "main \\(\\) at .*\r\n$gdb_prompt " "step" gdb_test "step" ".*" "step 4"; # Return from foo() gdb_test "step" "main \\(\\) at.*" "step 5" }