Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 18/24] Make gdb.gdb/complaints.exp use '-i $inferior_spawn_id' and gdb_test_stdio
Date: Tue, 21 Apr 2015 18:18:00 -0000	[thread overview]
Message-ID: <1429639711-16459-19-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1429639711-16459-1-git-send-email-palves@redhat.com>

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* gdb.gdb/complaints.exp (test_initial_complaints, test_serial_complaints)
	(test_short_complaints): Use gdb_test_stdio.
	(test_empty_complaint): Handle $inferior_spawn_id !=
	$gdb_spawn_id.
---
 gdb/testsuite/gdb.gdb/complaints.exp | 110 ++++++++++++++++++++---------------
 1 file changed, 64 insertions(+), 46 deletions(-)

diff --git a/gdb/testsuite/gdb.gdb/complaints.exp b/gdb/testsuite/gdb.gdb/complaints.exp
index 707b2a5..24843c0 100644
--- a/gdb/testsuite/gdb.gdb/complaints.exp
+++ b/gdb/testsuite/gdb.gdb/complaints.exp
@@ -24,15 +24,41 @@ if [target_info exists gdb,noinferiorio] {
     return
 }
 
-proc test_initial_complaints { } {
+# Similar to gdb_test_stdio, except no \r\n is expected before
+# $gdb_prompt in the $gdb_spawn_id.
 
+proc test_complaint {test inferior_io_re msg} {
+    global inferior_spawn_id gdb_spawn_id
     global gdb_prompt
 
+    set inferior_matched 0
+    set gdb_matched 0
+
+    gdb_test_multiple $test $msg {
+	-i $inferior_spawn_id -re "$inferior_io_re" {
+	    set inferior_matched 1
+	    if {!$gdb_matched} {
+		exp_continue
+	    }
+	}
+	-i $gdb_spawn_id -re "$gdb_prompt $" {
+	    set gdb_matched 1
+	    if {!$inferior_matched} {
+		exp_continue
+	    }
+	}
+    }
+
+    verbose -log "inferior_matched=$inferior_matched, gdb_matched=$gdb_matched"
+    gdb_assert {$inferior_matched && $gdb_matched} $msg
+}
+
+proc test_initial_complaints { } {
     # Unsupress complaints
     gdb_test "set stop_whining = 2"
 
     # Prime the system
-    gdb_test "call complaint (&symfile_complaints, \"Register a complaint\")" \
+    gdb_test_stdio "call complaint (&symfile_complaints, \"Register a complaint\")" \
 	    "During symbol reading, Register a complaint."
 
     # Check that the complaint was inserted and where
@@ -40,7 +66,7 @@ proc test_initial_complaints { } {
 	    ".\[0-9\]+ =.*\"Register a complaint\""
 
     # Re-issue the first message #1
-    gdb_test "call complaint (&symfile_complaints, symfile_complaints->root->fmt)" \
+    gdb_test_stdio "call complaint (&symfile_complaints, symfile_complaints->root->fmt)" \
 	    "During symbol reading, Register a complaint."
 
     # Check that there is only one thing in the list.  How the boolean
@@ -50,37 +76,29 @@ proc test_initial_complaints { } {
 	    ".\[0-9\]+ = \(1|true\)" "list has one entry"
 
     # Add a second complaint, expect it
-    gdb_test "call complaint (&symfile_complaints, \"Testing! Testing! Testing!\")" \
+    gdb_test_stdio "call complaint (&symfile_complaints, \"Testing! Testing! Testing!\")" \
 	    "During symbol reading, Testing. Testing. Testing.."
 
     return 0
 }
 
 proc test_serial_complaints { } {
-
-    global gdb_prompt
-
     gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 0)" "" "serial start"
 
     # Prime the system
-    gdb_test_multiple "call complaint (&symfile_complaints, \"serial line  1\")" "serial line 1" {
-	-re "During symbol reading...serial line  1...$gdb_prompt $" {
-	    pass "serial line 1"
-	}
-    }
+    test_complaint "call complaint (&symfile_complaints, \"serial line 1\")" \
+	"During symbol reading...serial line 1..." \
+	"serial line 1"
 
     # Add a second complaint, expect it
-    gdb_test_multiple "call complaint (&symfile_complaints, \"serial line 2\")" "serial line 2" {
-	-re "serial line 2...$gdb_prompt " {
-	    pass "serial line 2"
-	}
-    }
+    test_complaint "call complaint (&symfile_complaints, \"serial line 2\")" \
+	"serial line 2..." \
+	"serial line 2"
 
-    gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "serial end" {
-	-re "\r\n\r\n$gdb_prompt " {
-	    pass "serial end"
-	}
-    }
+    gdb_test_stdio "call clear_complaints (&symfile_complaints, 1, 0)" \
+	"\r\n" \
+	"" \
+	"serial end"
 
     return 0
 }
@@ -88,30 +106,22 @@ proc test_serial_complaints { } {
 # For short complaints, all are the same
 
 proc test_short_complaints { } {
-
-    global gdb_prompt
-
     gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 1)" "" "short start"
 
     # Prime the system
-    gdb_test_multiple "call complaint (&symfile_complaints, \"short line 1\")" "short line 1" {
-	-re "short line 1...$gdb_prompt " {
-	    pass "short line 1"
-	}
-    }
+    test_complaint "call complaint (&symfile_complaints, \"short line 1\")" \
+	"short line 1..." \
+	"short line 1"
 
     # Add a second complaint, expect it
-    gdb_test_multiple "call complaint (&symfile_complaints, \"short line 2\")" "short line 2" {
-	-re "short line 2...$gdb_prompt " {
-	    pass "short line 2"
-	}
-    }
+    test_complaint "call complaint (&symfile_complaints, \"short line 2\")" \
+	"short line 2..." \
+	"short line 2"
 
-    gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "short end" {
-	-re "\r\n\r\n$gdb_prompt " {
-	    pass "short end"
-	}
-    }
+    gdb_test_stdio "call clear_complaints (&symfile_complaints, 1, 0)" \
+	"\r\n" \
+	"" \
+	"short end"
 
     return 0
 }
@@ -122,12 +132,20 @@ proc test_short_complaints { } {
 
 proc test_empty_complaint { cmd msg } {
     global gdb_prompt
-    gdb_test_multiple $cmd $msg {
-	-re "\r\n\r\n$gdb_prompt $" {
-	    fail $msg
-	}
-	"\r\n$gdb_prompt $" {
-	    pass $msg
+    global inferior_spawn_id gdb_spawn_id
+
+    if {$gdb_spawn_id == $inferior_spawn_id} {
+	gdb_test_no_output $cmd $msg
+    } else {
+	set seen_output 0
+	gdb_test_multiple $cmd $msg {
+	    -i $inferior_spawn_id -re "." {
+		set seen_output 1
+		exp_continue
+	    }
+	    -i $gdb_spawn_id "$gdb_prompt $" {
+		gdb_assert !$seen_output $msg
+	    }
 	}
     }
 }
-- 
1.9.3


  parent reply	other threads:[~2015-04-21 18:18 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
2015-04-21 18:08 ` [PATCH 07/24] Introduce gdb_test_stdio Pedro Alves
2015-04-21 18:08 ` [PATCH 10/24] Make gdb.base/catch-gdb-caused-signals.exp use gdb_test_stdio Pedro Alves
2015-04-21 18:08 ` [PATCH 04/24] Don't rely on inferior I/O in gdb.base/siginfo-addr.exp Pedro Alves
2015-04-21 18:08 ` [PATCH 16/24] Make gdb.base/shlib-call.exp use gdb_test_stdio Pedro Alves
2015-04-21 18:08 ` [PATCH 01/24] gdb_test_multiple match eof of any spawn_id Pedro Alves
2015-04-21 18:08 ` [PATCH 12/24] Make gdb.base/a2-run.exp use $inferior_spawn_id and gdb_test_stdio Pedro Alves
2015-04-21 18:08 ` [PATCH 13/24] Make gdb.base/call-ar-st.exp use gdb_test_stdio Pedro Alves
2015-04-21 18:09 ` [PATCH 09/24] Make gdb.base/call-strs.exp " Pedro Alves
2015-04-21 18:09 ` [PATCH 20/24] Adjust MI to $inferior_spawn_id Pedro Alves
2015-04-21 18:09 ` [PATCH 17/24] Make gdb.base/varargs.exp use gdb_test_stdio Pedro Alves
2015-04-21 18:09 ` [PATCH 14/24] Make gdb.base/call-rt-st.exp use $inferior_spawn_id Pedro Alves
2015-04-21 18:09 ` [PATCH 06/24] Don't rely on inferior I/O in gdb.base/restore.exp Pedro Alves
2015-04-21 18:09 ` [PATCH 22/24] Unbuffer all tests that rely on stdio Pedro Alves
2015-04-21 18:09 ` [PATCH 03/24] Fix gdb.base/interrupt.exp racy fail against gdbserver Pedro Alves
2015-04-23 14:28   ` Yao Qi
2015-04-23 14:58     ` Pedro Alves
2015-04-21 18:09 ` [PATCH 24/24] Don't set gdb,noinferiorio on gdbserver boards Pedro Alves
2015-04-23 15:09   ` Yao Qi
2015-04-23 15:24     ` Pedro Alves
2015-04-24  9:19       ` Yao Qi
2015-04-21 18:09 ` [PATCH 11/24] Make gdb.base/dprintf.exp use gdb_test_stdio Pedro Alves
2015-04-21 18:09 ` [PATCH 19/24] Make gdb.gdb/selftest.exp use '-i $inferior_spawn_id' Pedro Alves
2015-04-21 18:09 ` [PATCH 23/24] interrupt.exp: Revert back to checking gdb,noinferiorio at the top Pedro Alves
2015-04-21 18:09 ` [PATCH 02/24] gdb.base/interrupt.exp: Rename saw_eof to saw_end_of_file Pedro Alves
2015-04-21 18:09 ` [PATCH 05/24] Don't rely on inferior I/O in {call-signal-resume, unwindonsignal}.exp Pedro Alves
2015-04-21 18:09 ` [PATCH 21/24] Make gdb.mi/mi-dprintf.exp use $inferior_spawn_id Pedro Alves
2015-04-21 18:15 ` [PATCH 08/24] Make gdb.base/sizeof.exp use gdb_test_stdio Pedro Alves
2015-04-23 15:36   ` Antoine Tremblay
2015-04-23 15:38     ` Antoine Tremblay
2015-04-23 15:49       ` Pedro Alves
2015-04-23 16:04         ` Pedro Alves
2015-04-23 16:25           ` Antoine Tremblay
2015-04-21 18:18 ` Pedro Alves [this message]
2015-04-21 18:43 ` [PATCH 15/24] Make gdb.base/ending-run.exp " Pedro Alves
2015-07-29 11:41 ` [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1429639711-16459-19-git-send-email-palves@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox