* [PATCH] gdb/testsuite: add binary testcases to py-format-string.exp
@ 2022-04-16 7:45 Enze Li
2022-04-18 13:29 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Enze Li @ 2022-04-16 7:45 UTC (permalink / raw)
To: gdb-patches
We currently only test decimal and hexadecimal for the
gdb.Value.format_string() interface, this patch adds testcases for
binary format.
Tested on x86_64 openSUSE Tumbleweed(VERSION_ID="20220413").
---
gdb/testsuite/gdb.python/py-format-string.exp | 37 +++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/gdb/testsuite/gdb.python/py-format-string.exp b/gdb/testsuite/gdb.python/py-format-string.exp
index ac1353ea2e3..63b87e73476 100644
--- a/gdb/testsuite/gdb.python/py-format-string.exp
+++ b/gdb/testsuite/gdb.python/py-format-string.exp
@@ -898,6 +898,43 @@ proc_with_prefix test_format {} {
}
}
+ # Binary.
+ set opts "format='t'"
+ with_test_prefix $opts {
+ set binary_pointer_regexp "\[0-1\]+"
+ gdb_test "python print (gdb.Value (42).format_string (${opts}))" \
+ "101010" \
+ "42 with option ${opts}"
+
+ check_format_string "a_point_t" $opts
+ check_format_string "a_point_t_pointer" $opts \
+ $binary_pointer_regexp
+ check_format_string "another_point" $opts
+ check_format_string "a_struct_with_union" $opts \
+ "\\{the_union = \\{an_int = 101010001010100010101000101010, a_char = 101010\\}\\}"
+ check_format_string "an_enum" $opts \
+ "1"
+ check_format_string "a_string" $opts \
+ $binary_pointer_regexp
+ check_format_string "a_binary_string" $opts \
+ $binary_pointer_regexp
+ check_format_string "a_binary_string_array" $opts \
+ "\\{1101000, 1100101, 1101100, 1101100, 1101111, 0, 1110111, 1101111, 1110010, 1101100, 1100100, 0\\}"
+ check_format_string "a_big_string" $opts \
+ "\\{1000001, 1000010, 1000011, 1000100, 1000101, \[, 0-1\]+\.\.\.\\}"
+ check_format_string "an_array" $opts \
+ "\\{10, 11, 101\\}"
+ check_format_string "an_array_with_repetition" $opts \
+ "\\{1, 11 <repeats 12 times>, 101, 101, 101\\}"
+ check_format_string "a_symbol_pointer" $opts \
+ $binary_pointer_regexp
+
+ if { $current_lang == "c++" } {
+ check_format_string "a_point_t_ref" $opts
+ check_format_string "a_base_ref" $opts
+ }
+ }
+
# Decimal.
set opts "format='d'"
with_test_prefix $opts {
--
2.35.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gdb/testsuite: add binary testcases to py-format-string.exp
2022-04-16 7:45 [PATCH] gdb/testsuite: add binary testcases to py-format-string.exp Enze Li
@ 2022-04-18 13:29 ` Tom Tromey
2022-04-21 12:48 ` Enze Li
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2022-04-18 13:29 UTC (permalink / raw)
To: Enze Li via Gdb-patches
>>>>> Enze Li via Gdb-patches <gdb-patches@sourceware.org> writes:
> We currently only test decimal and hexadecimal for the
> gdb.Value.format_string() interface, this patch adds testcases for
> binary format.
Thank you, this is ok.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gdb/testsuite: add binary testcases to py-format-string.exp
2022-04-18 13:29 ` Tom Tromey
@ 2022-04-21 12:48 ` Enze Li
0 siblings, 0 replies; 3+ messages in thread
From: Enze Li @ 2022-04-21 12:48 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On Mon, 2022-04-18 at 07:29 -0600, Tom Tromey wrote:
> > > > > > Enze Li via Gdb-patches <gdb-patches@sourceware.org>
> > > > > > writes:
>
> > We currently only test decimal and hexadecimal for the
> > gdb.Value.format_string() interface, this patch adds testcases for
> > binary format.
>
> Thank you, this is ok.
>
> Tom
Thanks for the review. Pushed.
Enze
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-21 12:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-16 7:45 [PATCH] gdb/testsuite: add binary testcases to py-format-string.exp Enze Li
2022-04-18 13:29 ` Tom Tromey
2022-04-21 12:48 ` Enze Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).