From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/6] Make gdb.python/py-inferior.exp test names unique
Date: Thu, 22 Oct 2015 11:23:00 -0000 [thread overview]
Message-ID: <1445507944-9197-2-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1445507944-9197-1-git-send-email-palves@redhat.com>
Before we had:
$ cat testsuite/gdb.sum | grep "PASS" | sort | uniq -c | sort -n
...
1 PASS: gdb.python/py-inferior.exp: write str
2 PASS: gdb.python/py-inferior.exp: Get inferior list length
2 PASS: gdb.python/py-inferior.exp: py start_addr = gdb.selected_frame ().read_var ('search_buf')
2 PASS: gdb.python/py-inferior.exp: Switch to first inferior
3 PASS: gdb.python/py-inferior.exp: find mixed-sized pattern
4 PASS: gdb.python/py-inferior.exp: py length = search_buf.type.sizeof
4 PASS: gdb.python/py-inferior.exp: py start_addr = search_buf.address
5 PASS: gdb.python/py-inferior.exp: Check inferior validity
$
gdb/testsuite/ChangeLog:
2015-10-22 Pedro Alves <palves@redhat.com>
* gdb.python/py-inferior.exp: Use with_test_prefix. Consistently
use lowercase.
---
gdb/testsuite/gdb.python/py-inferior.exp | 217 +++++++++++++++++--------------
1 file changed, 117 insertions(+), 100 deletions(-)
diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp
index b8ac9c8..8a20542 100644
--- a/gdb/testsuite/gdb.python/py-inferior.exp
+++ b/gdb/testsuite/gdb.python/py-inferior.exp
@@ -99,135 +99,152 @@ set one_pattern_found "${newline}.${dec_number}"
# Test string pattern.
-gdb_test "set *(int32_t*) &int8_search_buf\[10\] = 0x61616161" "" ""
-gdb_test "py search_buf = gdb.selected_frame ().read_var ('int8_search_buf')" "" ""
-gdb_test_no_output "py start_addr = search_buf.address"
-gdb_test_no_output "py length = search_buf.type.sizeof"
-
-gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, length, 'aaa'))" \
- "${one_pattern_found}" "find string pattern"
-
-# Test not finding pattern because search range too small, with
-# potential find at the edge of the range.
-
-gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, 10+3, 'aaaa'))" \
- "${pattern_not_found}" "pattern not found at end of range"
-
-# Increase the search range by 1 and we should find the pattern.
-
-gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, 10+3+1, 'aaa'))" \
- "${one_pattern_found}" "pattern found at end of range"
+with_test_prefix "string" {
+ gdb_test "set *(int32_t*) &int8_search_buf\[10\] = 0x61616161"
+ gdb_test "py search_buf = gdb.selected_frame ().read_var ('int8_search_buf')"
+ gdb_test_no_output "py start_addr = search_buf.address"
+ gdb_test_no_output "py length = search_buf.type.sizeof"
+
+ gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, length, 'aaa'))" \
+ "${one_pattern_found}" "find string pattern"
+
+ # Test not finding pattern because search range too small, with
+ # potential find at the edge of the range.
+ gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, 10+3, 'aaaa'))" \
+ "${pattern_not_found}" "pattern not found at end of range"
+
+ # Increase the search range by 1 and we should find the pattern.
+ gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, 10+3+1, 'aaa'))" \
+ "${one_pattern_found}" "pattern found at end of range"
+}
# Import struct to pack the following patterns.
gdb_test_no_output "py from struct import *"
# Test 16-bit pattern.
-gdb_test_no_output "set int16_search_buf\[10\] = 0x1234"
-gdb_test_no_output "py search_buf = gdb.selected_frame ().read_var ('int16_search_buf')"
-gdb_test_no_output "py start_addr = search_buf.address"
-gdb_test_no_output "py length = search_buf.type.sizeof"
-gdb_test_no_output "py pattern = pack('${python_pack_char}H',0x1234)"
-
-gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, length, pattern))" \
- "${one_pattern_found}" "find 16-bit pattern, with value pattern"
+with_test_prefix "16-bit" {
+ gdb_test_no_output "set int16_search_buf\[10\] = 0x1234"
+ gdb_test_no_output "py search_buf = gdb.selected_frame ().read_var ('int16_search_buf')"
+ gdb_test_no_output "py start_addr = search_buf.address"
+ gdb_test_no_output "py length = search_buf.type.sizeof"
+ gdb_test_no_output "py pattern = pack('${python_pack_char}H',0x1234)"
+ gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, length, pattern))" \
+ "${one_pattern_found}" "find 16-bit pattern, with value pattern"
+}
# Test 32-bit pattern.
-gdb_test_no_output "set int32_search_buf\[10\] = 0x12345678"
-gdb_test_no_output "py search_buf = gdb.selected_frame ().read_var ('int32_search_buf')"
-gdb_test_no_output "py start_addr = search_buf.address"
-gdb_test_no_output "py length = search_buf.type.sizeof"
-gdb_test_no_output "py pattern = pack('${python_pack_char}I',0x12345678)"
-
-gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, length, pattern))" \
- "${one_pattern_found}" "find 32-bit pattern, with python pattern"
+with_test_prefix "32-bit" {
+ gdb_test_no_output "set int32_search_buf\[10\] = 0x12345678"
+ gdb_test_no_output "py search_buf = gdb.selected_frame ().read_var ('int32_search_buf')"
+ gdb_test_no_output "py start_addr = search_buf.address"
+ gdb_test_no_output "py length = search_buf.type.sizeof"
+ gdb_test_no_output "py pattern = pack('${python_pack_char}I',0x12345678)"
+ gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, length, pattern))" \
+ "${one_pattern_found}" "find 32-bit pattern, with python pattern"
+}
# Test 64-bit pattern.
-gdb_test_no_output "set int64_search_buf\[10\] = 0xfedcba9876543210LL"
-gdb_test_no_output "py search_buf = gdb.selected_frame ().read_var ('int64_search_buf')"
-gdb_test_no_output "py start_addr = search_buf.address"
-gdb_test_no_output "py length = search_buf.type.sizeof"
-gdb_test_no_output "py pattern = pack('${python_pack_char}Q', 0xfedcba9876543210)"
-
-gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, length, pattern))" \
- "${one_pattern_found}" "find 64-bit pattern, with value pattern"
+with_test_prefix "64-bit" {
+ gdb_test_no_output "set int64_search_buf\[10\] = 0xfedcba9876543210LL"
+ gdb_test_no_output "py search_buf = gdb.selected_frame ().read_var ('int64_search_buf')"
+ gdb_test_no_output "py start_addr = search_buf.address"
+ gdb_test_no_output "py length = search_buf.type.sizeof"
+ gdb_test_no_output "py pattern = pack('${python_pack_char}Q', 0xfedcba9876543210)"
+ gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, length, pattern))" \
+ "${one_pattern_found}" "find 64-bit pattern, with value pattern"
+}
# Test mixed-sized patterns.
-gdb_test_no_output "set *(int8_t*) &search_buf\[10\] = 0x62"
-gdb_test_no_output "set *(int16_t*) &search_buf\[11\] = 0x6363"
-gdb_test_no_output "set *(int32_t*) &search_buf\[13\] = 0x64646464"
-gdb_test_no_output "py search_buf = gdb.selected_frame ().read_var ('search_buf')"
-gdb_test_no_output "py start_addr = search_buf\[0\].address"
-gdb_test_no_output "py pattern1 = pack('B', 0x62)"
-gdb_test_no_output "py pattern2 = pack('${python_pack_char}H', 0x6363)"
-gdb_test_no_output "py pattern3 = pack('${python_pack_char}I', 0x64646464)"
-
-gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, 100, pattern1))" \
- "${one_pattern_found}" "find mixed-sized pattern"
-gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, 100, pattern2))" \
- "${one_pattern_found}" "find mixed-sized pattern"
-gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, 100, pattern3))" \
- "${one_pattern_found}" "find mixed-sized pattern"
+with_test_prefix "mixed-sized" {
+ gdb_test_no_output "set *(int8_t*) &search_buf\[10\] = 0x62"
+ gdb_test_no_output "set *(int16_t*) &search_buf\[11\] = 0x6363"
+ gdb_test_no_output "set *(int32_t*) &search_buf\[13\] = 0x64646464"
+ gdb_test_no_output "py search_buf = gdb.selected_frame ().read_var ('search_buf')"
+ gdb_test_no_output "py start_addr = search_buf\[0\].address"
+ gdb_test_no_output "py pattern1 = pack('B', 0x62)"
+ gdb_test_no_output "py pattern2 = pack('${python_pack_char}H', 0x6363)"
+ gdb_test_no_output "py pattern3 = pack('${python_pack_char}I', 0x64646464)"
+
+ gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, 100, pattern1))" \
+ "${one_pattern_found}" "find mixed-sized pattern 1"
+ gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, 100, pattern2))" \
+ "${one_pattern_found}" "find mixed-sized pattern 2"
+ gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, 100, pattern3))" \
+ "${one_pattern_found}" "find mixed-sized pattern 3"
+}
# Test search spanning a large range, in the particular case of native
# targets, test the search spanning multiple chunks.
# Remote targets may implement the search differently.
set CHUNK_SIZE 16000
-
-gdb_test_no_output "set *(int32_t*) &search_buf\[0*${CHUNK_SIZE}+100\] = 0x12345678"
-gdb_test_no_output "set *(int32_t*) &search_buf\[1*${CHUNK_SIZE}+100\] = 0x12345678"
-gdb_test_no_output "py start_addr = gdb.selected_frame ().read_var ('search_buf')"
-gdb_test_no_output "py end_addr = start_addr + gdb.selected_frame ().read_var ('search_buf_size')"
-gdb_test_no_output "py pattern = pack('${python_pack_char}I', 0x12345678)"
-gdb_test_no_output "py first = gdb.inferiors()\[0\].search_memory (start_addr,end_addr - start_addr, pattern)"
-gdb_test "py print (first)" "${one_pattern_found}" "search spanning large range 1st result"
-gdb_test_no_output "py start_addr = first + 1"
-gdb_test_no_output "py second = gdb.inferiors()\[0\].search_memory (start_addr, end_addr - start_addr, pattern)"
-gdb_test "py print (second)" "${one_pattern_found}" "search spanning large range 2nd result"
-gdb_test_no_output "py start_addr = second + 1"
-gdb_test_no_output "py third = gdb.inferiors()\[0\].search_memory (start_addr, end_addr - start_addr, pattern)"
-gdb_test "py print (third)" "${pattern_not_found}" "search spanning large range 3rd result"
+with_test_prefix "large range" {
+ gdb_test_no_output "set *(int32_t*) &search_buf\[0*${CHUNK_SIZE}+100\] = 0x12345678"
+ gdb_test_no_output "set *(int32_t*) &search_buf\[1*${CHUNK_SIZE}+100\] = 0x12345678"
+ gdb_test_no_output "py start_addr = gdb.selected_frame ().read_var ('search_buf')"
+ gdb_test_no_output "py end_addr = start_addr + gdb.selected_frame ().read_var ('search_buf_size')"
+ gdb_test_no_output "py pattern = pack('${python_pack_char}I', 0x12345678)"
+
+ gdb_test_no_output "py first = gdb.inferiors()\[0\].search_memory (start_addr,end_addr - start_addr, pattern)"
+ gdb_test "py print (first)" "${one_pattern_found}" "search spanning large range 1st result"
+ gdb_test_no_output "py start_addr = first + 1"
+ gdb_test_no_output "py second = gdb.inferiors()\[0\].search_memory (start_addr, end_addr - start_addr, pattern)"
+ gdb_test "py print (second)" "${one_pattern_found}" "search spanning large range 2nd result"
+ gdb_test_no_output "py start_addr = second + 1"
+ gdb_test_no_output "py third = gdb.inferiors()\[0\].search_memory (start_addr, end_addr - start_addr, pattern)"
+ gdb_test "py print (third)" "${pattern_not_found}" "search spanning large range 3rd result"
+}
# For native targets, test a pattern straddling a chunk boundary.
if [isnative] {
- gdb_test_no_output "set *(int32_t*) &search_buf\[${CHUNK_SIZE}-1\] = 0xfdb97531"
- gdb_test_no_output "py pattern = pack('${python_pack_char}I', 0xfdb97531)"
- gdb_test_no_output "py start_addr = gdb.selected_frame ().read_var ('search_buf')"
- gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, end_addr - start_addr, pattern))" \
- "${one_pattern_found}" "find pattern straddling chunk boundary"
+ with_test_prefix "straddling" {
+ gdb_test_no_output "set *(int32_t*) &search_buf\[${CHUNK_SIZE}-1\] = 0xfdb97531"
+ gdb_test_no_output "py pattern = pack('${python_pack_char}I', 0xfdb97531)"
+ gdb_test_no_output "py start_addr = gdb.selected_frame ().read_var ('search_buf')"
+ gdb_test "py print (gdb.inferiors()\[0\].search_memory (start_addr, end_addr - start_addr, pattern))" \
+ "${one_pattern_found}" "find pattern straddling chunk boundary"
+ }
}
# Test Inferior is_valid. This must always be the last test in
# this testcase as it kills the inferior.
-gdb_py_test_silent_cmd "python inf_list = gdb.inferiors()" "get initial list" 1
-gdb_test "python print (len(inf_list))" "1" "Get inferior list length"
-gdb_test "python print (inf_list\[0\].is_valid())" "True" \
- "Check inferior validity"
-gdb_test "add-inferior" "Added inferior 2.*" "add empty inferior 2"
-gdb_py_test_silent_cmd "python inf_list = gdb.inferiors()" "get new list" 1
-gdb_test "python print (len(inf_list))" "2" "Get inferior list length"
-gdb_test "python print (inf_list\[0\].is_valid())" "True" \
- "Check inferior validity"
-gdb_test "python print (inf_list\[1\].is_valid())" "True" \
- "Check inferior validity"
-gdb_test_no_output "remove-inferiors 2" "remove-inferiors 3"
-gdb_test "python print (inf_list\[0\].is_valid())" "False" \
- "Check inferior validity"
-gdb_test "python print (inf_list\[1\].is_valid())" "True" \
- "Check inferior validity"
+with_test_prefix "is_valid" {
+ gdb_py_test_silent_cmd "python inf_list = gdb.inferiors()" "get initial list" 1
+ gdb_test "python print (len(inf_list))" "1" "get inferior list length 1"
+ gdb_test "python print (inf_list\[0\].is_valid())" "True" \
+ "check inferior validity 1"
+
+ gdb_test "add-inferior" "Added inferior 2.*" "add empty inferior 2"
+ gdb_py_test_silent_cmd "python inf_list = gdb.inferiors()" "get new list" 1
+ gdb_test "python print (len(inf_list))" "2" "get inferior list length 2"
+ gdb_test "python print (inf_list\[0\].is_valid())" "True" \
+ "check inferior validity 2"
+
+ gdb_test "python print (inf_list\[1\].is_valid())" "True" \
+ "check inferior validity 3"
+
+ gdb_test_no_output "remove-inferiors 2" "remove-inferiors 3"
+ gdb_test "python print (inf_list\[0\].is_valid())" "False" \
+ "check inferior validity 4"
+
+ gdb_test "python print (inf_list\[1\].is_valid())" "True" \
+ "check inferior validity 5"
+}
# Test gdb.selected_inferior()
-gdb_test "inferior 1" ".*" "Switch to first inferior"
-gdb_test "py print (gdb.selected_inferior().num)" "1" "First inferior selected"
-
-gdb_test "add-inferior" "Added inferior 3" "Create new inferior"
-gdb_test "inferior 3" ".*" "Switch to third inferior"
-gdb_test "py print (gdb.selected_inferior().num)" "3" "Third inferior selected"
-gdb_test "inferior 1" ".*" "Switch to first inferior"
-gdb_test_no_output "remove-inferiors 3" "Remove second inferior"
+with_test_prefix "selected_inferior" {
+ gdb_test "inferior 1" ".*" "switch to first inferior"
+ gdb_test "py print (gdb.selected_inferior().num)" "1" "first inferior selected"
+
+ gdb_test "add-inferior" "Added inferior 3" "create new inferior"
+ gdb_test "inferior 3" ".*" "switch to third inferior"
+ gdb_test "py print (gdb.selected_inferior().num)" "3" "third inferior selected"
+ gdb_test "inferior 1" ".*" "switch back to first inferior"
+ gdb_test_no_output "remove-inferiors 3" "remove second inferior"
+}
--
1.9.3
next prev parent reply other threads:[~2015-10-22 9:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-22 10:56 [PATCH 0/6] PR 17539 - inferiors/threads etc. print in reverse order Pedro Alves
2015-10-22 10:57 ` [PATCH 4/6] List checkpoints in ascending order Pedro Alves
2015-10-22 10:58 ` [PATCH 2/6] Linux: dump the signalled thread first Pedro Alves
2015-10-22 11:07 ` [PATCH 3/6] List inferiors/threads/pspaces in ascending order Pedro Alves
2015-10-22 16:03 ` Eli Zaretskii
2016-01-08 20:39 ` Regression for gdb.threads/fork-plus-threads.exp [Re: [PATCH 3/6] List inferiors/threads/pspaces in ascending order] Jan Kratochvil
2016-01-11 14:40 ` Pedro Alves
2016-01-12 11:22 ` Pedro Alves
2016-01-13 0:37 ` Pedro Alves
2015-10-22 11:23 ` Pedro Alves [this message]
2015-10-22 11:50 ` [PATCH 6/6] NEWS: "info" commands now list in ascending order Pedro Alves
2015-10-22 16:00 ` Eli Zaretskii
2015-10-22 16:06 ` Pedro Alves
2015-10-22 16:16 ` Eli Zaretskii
2015-10-22 12:36 ` [PATCH 5/6] List displays " Pedro Alves
2015-11-24 18:44 ` [PATCH 0/6] PR 17539 - inferiors/threads etc. print in reverse order 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=1445507944-9197-2-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