From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7872) id D066F380DBE6; Thu, 21 Apr 2022 12:50:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D066F380DBE6 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Enze Li To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite: add binary testcases to py-format-string.exp X-Act-Checkin: binutils-gdb X-Git-Author: Enze Li X-Git-Refname: refs/heads/master X-Git-Oldrev: 9cf71b1354f6829a999b39a675a18c5a85f19e17 X-Git-Newrev: 9d748d023d2df565e04974b5bb45618c24b30c15 Message-Id: <20220421125015.D066F380DBE6@sourceware.org> Date: Thu, 21 Apr 2022 12:50:15 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Apr 2022 12:50:15 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D9d748d023d2d= f565e04974b5bb45618c24b30c15 commit 9d748d023d2df565e04974b5bb45618c24b30c15 Author: Enze Li Date: Sat Apr 16 15:36:29 2022 +0800 gdb/testsuite: add binary testcases to py-format-string.exp =20 We currently only test decimal and hexadecimal for the gdb.Value.format_string() interface, this patch adds testcases for binary format. =20 Tested on x86_64 openSUSE Tumbleweed(VERSION_ID=3D"20220413"). Diff: --- 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 {} { } } =20 + # Binary. + set opts "format=3D'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 =3D \\{an_int =3D 101010001010100010101000101010, a_ch= ar =3D 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 , 101, 101, 101\\}" + check_format_string "a_symbol_pointer" $opts \ + $binary_pointer_regexp + + if { $current_lang =3D=3D "c++" } { + check_format_string "a_point_t_ref" $opts + check_format_string "a_base_ref" $opts + } + } + # Decimal. set opts "format=3D'd'" with_test_prefix $opts {