From: Pedro Alves <palves@redhat.com>
To: John Baldwin <jhb@freebsd.org>
Cc: Yao Qi <qiyaoltc@gmail.com>, gdb-patches@sourceware.org
Subject: [pushed] Fix gdb.base/starti.exp racy test (Re: [PATCH v3] Add a 'starti' command.)
Date: Thu, 16 Nov 2017 12:38:00 -0000 [thread overview]
Message-ID: <b376dd0f-279f-d03b-cbe1-7358d14f686a@redhat.com> (raw)
In-Reply-To: <81036fde-a756-594f-d347-e895b5f47037@redhat.com>
On 11/16/2017 10:53 AM, Pedro Alves wrote:
> Sounds like the sort of trouble you'd get if an earlier "(gdb)"
> prompt was left in expect's buffer, somehow.
Yup, that was (part of) it. I've pushed in the patch below.
From 968a13f8362072b5f7eae8584d490b53d7f97ca5 Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Thu, 16 Nov 2017 11:57:01 +0000
Subject: [PATCH] Fix gdb.base/starti.exp racy test
This commit fixes a couple problems with gdb.base/starti.exp, causing
spurious FAILs.
The first is a double-prompt problem:
~~~
(gdb) PASS: gdb.base/starti.exp: hook-stop
starti
[....]
gdb_expect_list pattern: /\$1 = 0/
$1 = 0
gdb_expect_list pattern: //
0x00007ffff7ddcc80 in _start () from /lib64/ld-linux-x86-64.so.2
(gdb) # EXPECTED PROMPT
(gdb) PASS: gdb.base/starti.exp: starti # ANOTHER PROMPT!
break main
~~~
This happens because the test uses gdb_test_sequence with no command,
like this:
gdb_test_sequence "" "starti" {
"Program stopped."
"\\$1 = 0"
}
but gdb_test_sequence doesn't have a check for empty command like
gdb_test_multiple does, and so sends "\n" to GDB:
proc gdb_test_sequence { command test_name expected_output_list } {
global gdb_prompt
if { $test_name == "" } {
set test_name $command
}
lappend expected_output_list ""; # implicit ".*" before gdb prompt
send_gdb "$command\n"
return [gdb_expect_list $test_name "$gdb_prompt $" $expected_output_list]
}
"starti" is a no-repeat command, so pressing <ret> just makes another
prompt appear, confusing the following gdb_test/gdb_test_multiple/etc.
Even with that fixed, the testcase is still racy though.
The second problem is that sometimes the "continue" test times out
here:
~~~
continue
Continuing.
$2 = 1
gdb_expect_list pattern: /.*Breakpoint .*main \(\) at .*starti.c.*/
Breakpoint 1, main () at /home/pedro/src/gdb/testsuite/gdb.base/starti.c:29
29 return 0;
(gdb) gdb_expect_list pattern: //
* hung here *
~~~
The problem is that the too-greedy ".*" trailing match in
gdb_expect_list's pattern ends up consuming GDB's prompt too soon.
Fix that by removing the unnecessary trailing ".*". While at it,
remove all ".*"s to be stricter.
Tested on x86_64 GNU/Linux.
gdb/testsuite/ChangeLog:
2017-11-16 Pedro Alves <palves@redhat.com>
* gdb.base/starti.exp ("continue" test): Remove ".*"s from
pattern.
* lib/gdb.exp (gdb_test_sequence): Don't send empty command to
GDB.
---
gdb/testsuite/ChangeLog | 7 +++++++
gdb/testsuite/gdb.base/starti.exp | 2 +-
gdb/testsuite/lib/gdb.exp | 7 +++++--
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index bb8dd79..547a3be 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2017-11-16 Pedro Alves <palves@redhat.com>
+
+ * gdb.base/starti.exp ("continue" test): Remove ".*"s from
+ pattern.
+ * lib/gdb.exp (gdb_test_sequence): Don't send empty command to
+ GDB.
+
2017-11-15 Simon Marchi <simon.marchi@ericsson.com>
* gdb.tui/completionn.exp (test_tab_completion): Add space in
diff --git a/gdb/testsuite/gdb.base/starti.exp b/gdb/testsuite/gdb.base/starti.exp
index 98167ce..76e68d5 100644
--- a/gdb/testsuite/gdb.base/starti.exp
+++ b/gdb/testsuite/gdb.base/starti.exp
@@ -47,5 +47,5 @@ gdb_test_sequence "" "starti" {
gdb_breakpoint main
gdb_test_sequence "continue" "" {
"\\$2 = 1"
- ".*Breakpoint .*main \\(\\) at .*starti.c.*"
+ "Breakpoint \[^\r\n\]*main \\(\\) at \[^\r\n\]*starti.c"
}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 548cb06..8d6972a 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1093,7 +1093,8 @@ proc gdb_test_no_output { args } {
# This is useful when the sequence is long and contains ".*", a single
# regexp to match the entire output can get a timeout much easier.
#
-# COMMAND is the command to send.
+# COMMAND is the command to execute, send to GDB with send_gdb. If
+# this is the null string no command is sent.
# TEST_NAME is passed to pass/fail. COMMAND is used if TEST_NAME is "".
# EXPECTED_OUTPUT_LIST is a list of regexps of expected output, which are
# processed in order, and all must be present in the output.
@@ -1116,7 +1117,9 @@ proc gdb_test_sequence { command test_name expected_output_list } {
set test_name $command
}
lappend expected_output_list ""; # implicit ".*" before gdb prompt
- send_gdb "$command\n"
+ if { $command != "" } {
+ send_gdb "$command\n"
+ }
return [gdb_expect_list $test_name "$gdb_prompt $" $expected_output_list]
}
--
2.5.5
next prev parent reply other threads:[~2017-11-16 12:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-11 22:08 [PATCH v3] Add a 'starti' command John Baldwin
2017-09-18 23:15 ` John Baldwin
2017-09-19 14:35 ` Pedro Alves
2017-09-19 18:23 ` John Baldwin
2017-09-19 18:29 ` Pedro Alves
2017-11-03 13:00 ` Yao Qi
2017-11-15 20:11 ` John Baldwin
2017-11-15 20:23 ` Pedro Alves
2017-11-15 23:32 ` John Baldwin
2017-11-16 10:54 ` Pedro Alves
2017-11-16 12:38 ` Pedro Alves [this message]
2017-11-16 18:00 ` [pushed] Fix gdb.base/starti.exp racy test (Re: [PATCH v3] Add a 'starti' command.) John Baldwin
2017-11-16 18:15 ` Pedro Alves
2017-11-16 9:55 ` [PATCH v3] Add a 'starti' command Yao Qi
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=b376dd0f-279f-d03b-cbe1-7358d14f686a@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=jhb@freebsd.org \
--cc=qiyaoltc@gmail.com \
/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