From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Cc: Wei-cheng Wang <cole945@gmail.com>
Subject: Re: [PATCH] Fix memory-region overlapping checking
Date: Wed, 08 Aug 2012 10:31:00 -0000 [thread overview]
Message-ID: <1450628.xUgDUToN8c@qiyao.dyndns.org> (raw)
In-Reply-To: <CAPmZyH65a8B0=9wwMVHhDC-eTxOQ1==MRhhcFP=bDuZCJa9tBQ@mail.gmail.com>
Wei-cheng,
Thanks for writing a test. Some comments below,
On Tuesday, August 07, 2012 02:01:59 PM Wei-cheng Wang wrote:
> +
> +#
> +# Test overlapping checking
> +#
> +# lo' hi'
> +# |---------|
> +# 10 20 30 40 50 60 70 80
> +# |----| FAIL
> +# |---| FAIL
> +# |----| FAIL
> +# |-------------| FAIL
> +# |----| PASS
> +# |----| PASS
> +
> +proc delete_memory {} {
> + global gdb_prompt
> +
> + send_gdb "delete mem\n"
> + gdb_expect 100 {
> + -re "Delete all memory regions.*y or n.*$" {
> + send_gdb "y\n";
> + exp_continue
> + }
> + -re "$gdb_prompt $" { }
> + }
We can use gdb_test_multiple here.
> +}
> +
> +# Test normal case (upper != 0)
> +delete_memory
> +send_gdb "mem 0x30 0x60 ro\n"; gdb_expect -re "$gdb_prompt $"
We can use gdb_test_no_output "mem 0x30 0x60 ro"
> +gdb_test "mem 0x20 0x40 ro" "overlapping memory region"
> +gdb_test "mem 0x40 0x50 ro" "overlapping memory region"
> +gdb_test "mem 0x50 0x70 ro" "overlapping memory region"
> +gdb_test_no_output "mem 0x10 0x30 ro"
> +gdb_test_no_output "mem 0x60 0x80 ro"
> +
> +# Test sepcial case (upper == 0)
^^^^^^^ typo "special"
> +delete_memory
> +send_gdb "mem 0x30 0x0 ro\n"; gdb_expect -re "$gdb_prompt $"
gdb_test_no_output
> +gdb_test "mem 0x20 0x40 ro" "overlapping memory region"
> +gdb_test "mem 0x40 0x50 ro" "overlapping memory region"
> +gdb_test "mem 0x50 0x70 ro" "overlapping memory region"
> +gdb_test_no_output "mem 0x10 0x30 ro"
the test result in summary is *not* unique,
$ cat testsuite/gdb.sum | grep "PASS" | sort | uniq -c | sort -n
....
2 PASS: gdb.base/memattr.exp: mem 0x20 0x40 ro
2 PASS: gdb.base/memattr.exp: mem 0x40 0x50 ro
2 PASS: gdb.base/memattr.exp: mem 0x50 0x70 ro
See more about this rule here
http://sourceware.org/gdb/wiki/GDBTestcaseCookbook#Make_sure_test_messages_are_unique
Below is a new one fixed all the issues in your original patch. What do you
think?
Without your fix, the new test exposes a fail,
FAIL: gdb.base/memattr.exp: 0x10 0x30 2
and fail is fixed with the patch applied.
--
Yao (齐尧)
2012-08-08 Wei-cheng Wang <cole945@gmail.com>
Yao Qi <yao@codesourcery.com>
* gdb.base/memattr.exp: Add cases for overlapping checking.
diff --git INDEX:/gdb/testsuite/gdb.base/memattr.exp
--- INDEX:/gdb/testsuite/gdb.base/memattr.exp
+++ WORKDIR:/gdb/testsuite/gdb.base/memattr.exp
@@ -448,3 +448,45 @@ gdb_test_multiple "info mem" "mem 2-4 were deleted" {
gdb_test "delete mem 8" "No memory region number 8." \
"delete non-existant region"
+
+#
+# Test overlapping checking
+#
+# lo' hi'
+# |---------|
+# 10 20 30 40 50 60 70 80
+# |----| FAIL
+# |---| FAIL
+# |----| FAIL
+# |-------------| FAIL
+# |----| PASS
+# |----| PASS
+
+proc delete_memory {} {
+ global gdb_prompt
+
+ gdb_test_multiple "delete mem" "delete mem" {
+ -re "Delete all memory regions.*y or n.*$" {
+ send_gdb "y\n";
+ exp_continue
+ }
+ -re "$gdb_prompt $" { }
+ }
+}
+
+# Test normal case (upper != 0)
+delete_memory
+gdb_test_no_output "mem 0x30 0x60 ro"
+gdb_test "mem 0x20 0x40 ro" "overlapping memory region" "0x20 0x40 1"
+gdb_test "mem 0x40 0x50 ro" "overlapping memory region" "0x40 0x50 1"
+gdb_test "mem 0x50 0x70 ro" "overlapping memory region" "0x50 0x70 1"
+gdb_test_no_output "mem 0x10 0x30 ro" "0x10 0x30 1"
+gdb_test_no_output "mem 0x60 0x80 ro"
+
+# Test special case (upper == 0)
+delete_memory
+gdb_test_no_output "mem 0x30 0x0 ro"
+gdb_test "mem 0x20 0x40 ro" "overlapping memory region" "0x20 0x40 2"
+gdb_test "mem 0x40 0x50 ro" "overlapping memory region" "0x40 0x50 2"
+gdb_test "mem 0x50 0x70 ro" "overlapping memory region" "0x50 0x70 2"
+gdb_test_no_output "mem 0x10 0x30 ro" "0x10 0x30 2"
next prev parent reply other threads:[~2012-08-08 10:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-02 6:11 Wei-cheng Wang
2012-08-02 8:10 ` Yao Qi
2012-08-02 10:00 ` Wei-cheng Wang
2012-08-03 10:54 ` Yao Qi
2012-08-07 2:35 ` Wei-cheng Wang
2012-08-07 2:48 ` Yao Qi
2012-08-07 6:02 ` Wei-cheng Wang
2012-08-08 10:31 ` Yao Qi [this message]
2012-08-16 10:03 ` Wei-cheng Wang
2012-08-24 11:18 ` Pedro Alves
2012-08-24 11:47 ` Wei-cheng Wang
2012-08-24 15:12 ` Pedro Alves
2012-08-27 2:22 ` Wei-cheng Wang
2012-08-27 8:58 ` 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=1450628.xUgDUToN8c@qiyao.dyndns.org \
--to=yao@codesourcery.com \
--cc=cole945@gmail.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