Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Marek Polacek <mpolacek@redhat.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [RFC] gdb.cp/static-print-quit.exp: fix racy tests (PR testsuite/12649)
Date: Fri, 06 May 2011 02:15:00 -0000	[thread overview]
Message-ID: <20110506021511.GA30222@host1.jankratochvil.net> (raw)
In-Reply-To: <4DC2E877.6080808@redhat.com> <4DC2E674.1060608@redhat.com>

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
     }
 }
 


  parent reply	other threads:[~2011-05-06  2:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-05 18:03 Marek Polacek
2011-05-05 18:12 ` Marek Polacek
2011-05-06  2:15 ` Jan Kratochvil [this message]
2011-05-06  8:58   ` Marek Polacek
2011-05-06 11:09     ` Pierre Muller
2011-05-06 11:15       ` Marek Polacek
2011-05-06 13:41     ` Jan Kratochvil

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=20110506021511.GA30222@host1.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mpolacek@redhat.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