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 2/6] gdb.base/interrupt.exp: Use gdb_test_multiple instead of gdb_expect
Date: Mon, 23 Feb 2015 13:54:00 -0000	[thread overview]
Message-ID: <1424699660-11727-3-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1424699660-11727-1-git-send-email-palves@redhat.com>

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

	* gdb.base/interrupt.exp: Use gdb_test_multiple instead of
	gdb_expect.
---
 gdb/testsuite/gdb.base/interrupt.exp | 89 ++++++++++++++++++++----------------
 1 file changed, 49 insertions(+), 40 deletions(-)

diff --git a/gdb/testsuite/gdb.base/interrupt.exp b/gdb/testsuite/gdb.base/interrupt.exp
index 82137e6..55c8fca 100644
--- a/gdb/testsuite/gdb.base/interrupt.exp
+++ b/gdb/testsuite/gdb.base/interrupt.exp
@@ -49,24 +49,24 @@ if ![file exists $binfile] then {
     gdb_test "shell stty intr '^C'" ".*" \
 	"set interrupt character in interrupt.exp"
     if [runto_main] then {
-	send_gdb "continue\n"
-	gdb_expect {
-	    -re "\r\ntalk to me baby\r\n$" {
-		pass "child process is alive"
+	set msg "process is alive"
+	gdb_test_multiple "continue" $msg {
+	    -re "\r\ntalk to me baby\r\n" {
+		pass $msg
 	    }
-	    timeout { fail "run (timeout)" }
-	    eof { fail "run (eof)" }
 	}
+
 	# This should appear twice, once for the echo and once for the
 	# program's output.
+
+	set msg "child process ate our char"
 	send_gdb "a\n"
-	gdb_expect {
+	gdb_test_multiple "" $msg {
 	    -re "^a\r\na\r\n$" {
-		pass "child process ate our char"
+		pass $msg
 	    }
-	    timeout { fail "echo a (timeout)" }
-	    eof { fail "echo a (eof)" }
 	}
+
 	# Wait until the program is in the read system call again.
 	sleep 2
 
@@ -79,18 +79,19 @@ if ![file exists $binfile] then {
 	# the read and delivering the cntrl-c.
 
 	send_gdb "\003"
-	gdb_expect {
+	set msg "send_gdb control C"
+	gdb_test_multiple "" $msg {
 	    -re "Program received signal SIGINT.*$gdb_prompt $" {
-		pass "send_gdb control C"
+		pass $msg
 	    }
-	    -re ".*$gdb_prompt $" { fail "send_gdb control C" }
-	    timeout { fail "send_gdb control C (timeout)" }
-	    eof { fail "send_gdb control C (eof)" }
 	}
 
+	set msg "call function when asleep"
 	send_gdb "p func1 ()\n"
-	gdb_expect {
-	    -re " = 4.*$gdb_prompt $" { pass "call function when asleep" }
+	gdb_test_multiple "" $msg {
+	    -re " = 4.*$gdb_prompt $" {
+		pass $msg
+	    }
 	    -re ".*Program received signal SIG(SEGV|ILL).*$gdb_prompt $" {
 		setup_xfail "i*86-pc-linux*-gnu*"
 		fail "child died when we called func1, skipped rest of tests"
@@ -118,12 +119,11 @@ if ![file exists $binfile] then {
 		setup_xfail "*-*-*bsd*"
 		setup_xfail "*-*-hpux*"
 		setup_xfail "*-*-*lynx*"
-		fail "call function when asleep (stays asleep)"
+		fail "$msg (stays asleep)"
 		# Send_Gdb a newline to wake it up
 		send_gdb "\n"
 		gdb_test "" " = 4" "call function after waking it"
 	    }
-#	    eof { fail "call function when asleep (eof)" }
 	}
 
 	# Now try calling the function again.
@@ -137,12 +137,15 @@ if ![file exists $binfile] then {
 	send_gdb "continue\n"
 	# For some reason, i386-*-sysv4 gdb fails to issue the Continuing
 	# message, but otherwise appears normal (FIXME).
-	gdb_expect {
-	    -re "^continue\r\nContinuing.\r\n(\r\n|)$" { pass "continue" }
-	    -re "^continue\r\n\r\n" { fail "continue (missing Continuing.)" }
-	    -re "$gdb_prompt $" { fail "continue" }
-	    timeout { fail "continue (timeout)" }
-	    eof { fail "continue (eof)" }
+
+	set msg "continue"
+	gdb_test_multiple "" "$msg" {
+	    -re "^continue\r\nContinuing.\r\n(\r\n|)$" {
+		pass $msg
+	    }
+	    -re "^continue\r\n\r\n" {
+		fail "$msg (missing Continuing.)"
+	    }
 	}
 
 	send_gdb "data\n"
@@ -152,11 +155,15 @@ if ![file exists $binfile] then {
         # FIXME: The pattern below leads to an expected success on HPUX-11.0
         # but the success is spurious. Need to provide the right reg.expr.
         # here.
-	gdb_expect {
-	    -re "^(\r\n|)data\r\ndata\r\n$" { pass "echo data" }
-	    -re "Undefined command.*$gdb_prompt " { fail "echo data" }
-	    timeout { fail "echo data (timeout)" }
-	    eof { fail "echo data (eof)" }
+
+	set msg "echo data"
+	gdb_test_multiple "" $msg {
+	    -re "^(\r\n|)data\r\ndata\r\n$" {
+		pass $msg
+	    }
+	    -re "Undefined command.*$gdb_prompt " {
+		fail $msg
+	    }
 	}
 
  	if { ! [target_info exists gdb,nosignals] } {
@@ -176,26 +183,28 @@ if ![file exists $binfile] then {
 	    # return to the loop.
 	    set msg "signal SIGINT"
 	    gdb_test_multiple "signal SIGINT" "$msg" {
-		-re "^signal SIGINT\r\nContinuing with signal SIGINT.\r\n(\r\n|)$" { pass "$msg" }
+		-re "^signal SIGINT\r\nContinuing with signal SIGINT.\r\n(\r\n|)$" {
+		    pass "$msg"
+		}
 	    }
 
 	    # We should be back in the loop.
 	    send_gdb "more data\n"
-	    gdb_expect {
-		-re "^(\r\n|)more data\r\nmore data\r\n$" { pass "echo more data" }
-		timeout { fail "echo more data (timeout)" }
-		eof { fail "echo more data (eof)" }
+
+	    set msg "echo more data"
+	    gdb_test_multiple "" $msg {
+		-re "^(\r\n|)more data\r\nmore data\r\n$" {
+		    pass $msg
+		}
 	    }
 	}
 
+	set msg "send end of file"
 	send_gdb "\004"
-	gdb_expect {
+	gdb_test_multiple "" $msg {
 	    -re "end of file.*$inferior_exited_re normally.*$gdb_prompt $" {
-		pass "send end of file"
+		pass $msg
 	    }
-	    -re "$gdb_prompt $" { fail "send end of file" }
-	    timeout { fail "send end of file (timeout)" }
-	    eof { fail "send end of file (eof)" }
 	}
     }
 }
-- 
1.9.3


  parent reply	other threads:[~2015-02-23 13:54 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-23 13:54 [PATCH 0/6] Introduce $inferior_spawn_id, make interrupt.exp work with GDBserver Pedro Alves
2015-02-23 13:54 ` [PATCH 1/6] gdb.base/interrupt.exp: Fix race Pedro Alves
2015-02-23 13:54 ` [PATCH 3/6] gdb_test_multiple: Fix user code argument processing Pedro Alves
2015-02-23 13:54 ` [PATCH 4/6] testsuite: Don't use expect_background to reap gdbserver Pedro Alves
2015-04-13 11:42   ` Yao Qi
2015-04-13 12:09     ` Pedro Alves
2015-04-13 13:25       ` Yao Qi
2015-04-13 13:52         ` Pedro Alves
2015-04-13 14:20           ` Yao Qi
2015-04-13 14:22             ` Pedro Alves
2015-04-13 14:48               ` Yao Qi
2015-02-23 13:54 ` Pedro Alves [this message]
2015-02-23 13:54 ` [PATCH 6/6] gdb.base/interrupt.exp: Use send_inferior/$inferior_spawn_id Pedro Alves
2015-02-23 14:28 ` [PATCH 5/6] testsuite: Introduce $inferior_spawn_id Pedro Alves
2015-02-24 16:31   ` Yao Qi
2015-02-27 10:42     ` Pedro Alves
2015-02-27 10:59       ` Pedro Alves
2015-02-27 11:01         ` Pedro Alves
2015-02-27 12:12         ` Yao Qi
2015-02-27 13:59           ` [pushed] Add "../lib/unbuffer_output.c" and use it in gdb.base/interrupt.c (Re: [PATCH 5/6] testsuite: Introduce $inferior_spawn_id) Pedro Alves
2015-02-27 14:13             ` Yao Qi
2015-02-27 14:42             ` Eli Zaretskii
2015-02-27 14:47               ` Pedro Alves
2015-02-27 12:08       ` [PATCH 5/6] testsuite: Introduce $inferior_spawn_id Yao Qi
2015-02-27 12:30         ` Pedro Alves
2015-04-16 16:55           ` Antoine Tremblay
2015-04-16 17:14             ` Pedro Alves
2015-04-21 18:25               ` Pedro Alves
2015-04-21 18:32                 ` Antoine Tremblay
2015-04-07 17:31 ` [PATCH 0/6] Introduce $inferior_spawn_id, make interrupt.exp work with GDBserver 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=1424699660-11727-3-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