This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC] gdb.cp/static-print-quit.exp: fix racy tests (PR testsuite/12649)
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Marek Polacek <mpolacek at redhat dot com>
- Cc: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Fri, 6 May 2011 04:15:12 +0200
- Subject: Re: [RFC] gdb.cp/static-print-quit.exp: fix racy tests (PR testsuite/12649)
On Thu, 05 May 2011 20:03:32 +0200, Marek Polacek wrote:
[...]
> We can prevent this if we, in our gdb_test_multiple, create a "<return>"
> case with `exp_continue'. Nonetheless, except this, we must also in this
> case:
>
> -re " to quit---$" {
> fail $test
> return -1
> }
Found comments for the testcase were:
[patch] Fix memory corruption on aborted object print
http://sourceware.org/ml/gdb-patches/2010-06/msg00632.html
47c8c764a9be6d023eca450336e6d9de16970fc0
The " to quit---$" case was there probably for the gdb-7.1 case which is
missing the "static field" output, put there untested now. I understand this
is a change of the testcase.
> differentiate between success and failure, since after processing the "<return>"
> part we now have in the buffer " to quit---". Thus, it is possible to do
> something like this, using a new variable `seen_return', although I must say, I don't
> like it at all.
exp_continue/variables make it complicated, I would prefer splitting it to
multiple consecutive test cases.
> set test "print c"
> set seen_return 0
> gdb_test_multiple $test $test {
> "<return>" {
> incr seen_return
> exp_continue
> }
BTW you do not need to match exactly "<return>" as is in lib/gdb.exp - it is
enough to match any string ending with "<return>".
On Thu, 05 May 2011 20:12:07 +0200, Marek Polacek wrote:
> I should have add a diff as well, here it is:
[...]
> - -re " = \{loooooooooooooooooooooooooooooooooooooooooooooong = 0, static field = \{\r\n---Type <return> to continue, or q <return> to quit---$" {
> - pass $test
> + "<return>" {
> + incr seen_return
FYI the diff could not be applied as it has <tab>s converted to spaces.
Any comments? I will check it in otherwise.
Tested on x86_64-fedora15-linux-gnu.
Thanks,
Jan
gdb/testsuite/
2011-05-06 Jan Kratochvil <jan.kratochvil@redhat.com>
Fix a race.
* gdb.cp/static-print-quit.exp (print c): Split to ...
(print c - <return>, print c - q <return>, print c - to quit):
... these. Make the testfile untested on gdb-7.1.
--- a/gdb/testsuite/gdb.cp/static-print-quit.exp
+++ b/gdb/testsuite/gdb.cp/static-print-quit.exp
@@ -30,14 +30,29 @@ clean_restart $executable
gdb_test_no_output "set width 80"
gdb_test_no_output "set height 2"
-set test "print c"
-gdb_test_multiple $test $test {
- -re " = \{loooooooooooooooooooooooooooooooooooooooooooooong = 0, static field = \{\r\n---Type <return> to continue, or q <return> to quit---$" {
+set test "print c - <return>"
+gdb_test_multiple "print c" $test {
+ -re "\\$\[0-9\]+ = \{loooooooooooooooooooooooooooooooooooooooooooooong = 0, static field = \{\r\n---Type <return>" {
pass $test
}
+ -re "\r\n---Type <return>" {
+ # gdb-7.1 did not crash with this testcase but it had the same bug.
+ untested ${testfile}.exp
+ return 0
+ }
+}
+
+set test "print c - q <return>"
+gdb_test_multiple "" $test {
+ -re " to continue, or q <return>" {
+ pass $test
+ }
+}
+
+set test "print c - to quit"
+gdb_test_multiple "" $test {
-re " to quit---$" {
- fail $test
- return -1
+ pass $test
}
}