public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb/testsuite: Fix race in gdb.dwarf2/calling-convention.exp
@ 2022-04-14 17:21 Lancelot SIX
  0 siblings, 0 replies; only message in thread
From: Lancelot SIX @ 2022-04-14 17:21 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a79fa8c5fb5a8a09da25c6858381d8f34b597c12

commit a79fa8c5fb5a8a09da25c6858381d8f34b597c12
Author: Lancelot SIX <lancelot.six@amd.com>
Date:   Thu Apr 14 18:21:04 2022 +0100

    gdb/testsuite: Fix race in gdb.dwarf2/calling-convention.exp
    
    Pedro Alves warned me that there is a race in
    gdb.dwarf2/calling-convention.exp making the test sometimes fail on his
    setup.  This can be reliably reproduced using :
    
        make check-read1 TESTS="gdb.dwarf2/calling-convention.exp"
    
    The relevant part of the gdb.log file is:
    
        return 35
        Function 'foo' does not follow the target calling convention.
        If you continue, setting the return value will probably lead to unpredictable behaviors.
        Make foo return now? (y or n) PASS: gdb.dwarf2/calling-convention.exp: return 35
        n
        Not confirmed
        (gdb) FAIL: gdb.dwarf2/calling-convention.exp: finish
    
    The issue is that when doing the test for "return 35", the DejaGnu test
    sends "n" (to tell GDB not to perform the return action) but never
    consumes the "Not confirmed" acknowledgment sent by GDB.  Later, when
    trying to do the next test, DejaGnu tries to match the leftover output
    from the "return" test. As this output is not expected, the test fails.
    
    Fix by using gdb_test to send the "n" answer and match the confirmation
    and consume all output to the prompt.
    
    Also do minor adjustments to the main regex:
      - Remove the leading ".*" which is not required.
      - Ensure that the "?" from the question is properly escaped.
    
    Tested on x86_64-gnu-linux, using
    
    - make check TESTS="gdb.dwarf2/calling-convention.exp"
    - make check-read1 TESTS="gdb.dwarf2/calling-convention.exp"
    - make check-readmore TESTS="gdb.dwarf2/calling-convention.exp"
    
    Co-authored-by: Pedro Alves <pedro@palves.net>
    Change-Id: I42858b13db2cbd623c5c1739de65ad423e0c0938

Diff:
---
 gdb/testsuite/gdb.dwarf2/calling-convention.exp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.dwarf2/calling-convention.exp b/gdb/testsuite/gdb.dwarf2/calling-convention.exp
index 0a11cb15c68..77107a42350 100644
--- a/gdb/testsuite/gdb.dwarf2/calling-convention.exp
+++ b/gdb/testsuite/gdb.dwarf2/calling-convention.exp
@@ -84,9 +84,9 @@ gdb_breakpoint "foo"
 gdb_continue_to_breakpoint "foo"
 
 gdb_test_multiple "return 35" "" {
-    -re ".*Function 'foo' does not follow the target calling convention.\r\nIf you continue, setting the return value will probably lead to unpredictable behaviors.\r\nMake foo return now?.*\\(y or n\\) $" {
-	send_gdb "n\n"
+    -re "Function 'foo' does not follow the target calling convention.\r\nIf you continue, setting the return value will probably lead to unpredictable behaviors.\r\nMake foo return now\\? \\(y or n\\) $" {
 	pass $gdb_test_name
+	gdb_test "n" "Not confirmed" "cancel return"
     }
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-14 17:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-14 17:21 [binutils-gdb] gdb/testsuite: Fix race in gdb.dwarf2/calling-convention.exp Lancelot SIX

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).