From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id E6B123852752; Tue, 14 Jun 2022 17:50:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E6B123852752 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/testsuite] Handle unordered dict in gdb.python/py-mi-cmd.exp X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 965b71a7f739a747c6b427a96b1fa9dd26e38956 X-Git-Newrev: 362a867f2ac16f597d06e8a9a3f6c15afa7adf6f Message-Id: <20220614175050.E6B123852752@sourceware.org> Date: Tue, 14 Jun 2022 17:50:50 +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: Tue, 14 Jun 2022 17:50:51 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D362a867f2ac1= 6f597d06e8a9a3f6c15afa7adf6f commit 362a867f2ac16f597d06e8a9a3f6c15afa7adf6f Author: Tom de Vries Date: Tue Jun 14 19:50:44 2022 +0200 [gdb/testsuite] Handle unordered dict in gdb.python/py-mi-cmd.exp =20 When running test-case gdb.python/py-mi-cmd.exp on openSUSE Leap 42.3 w= ith python 3.4, I occasionally run into: ... Expecting: ^(-pycmd dct[^M ]+)?(\^done,result=3D{hello=3D"world",times=3D"42"}[^M ]+[(]gdb[)] ^M [ ]*) -pycmd dct^M ^done,result=3D{times=3D"42",hello=3D"world"}^M (gdb) ^M FAIL: gdb.python/py-mi-cmd.exp: -pycmd dct (unexpected output) ... =20 The problem is that the data type used here in py-mi-cmd.py: ... elif argv[0] =3D=3D "dct": return {"result": {"hello": "world", "times": 42}} ... is a dictionary, and only starting version 3.6 are dictionaries inserti= on ordered, so using PyDict_Next in serialize_mi_result doesn't guarantee a fixed order. =20 Fix this by allowing the alternative order. =20 Tested on x86_64-linux. Diff: --- gdb/testsuite/gdb.python/py-mi-cmd.exp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.python/py-mi-cmd.exp b/gdb/testsuite/gdb.pyt= hon/py-mi-cmd.exp index d372518a031..733686098f8 100644 --- a/gdb/testsuite/gdb.python/py-mi-cmd.exp +++ b/gdb/testsuite/gdb.python/py-mi-cmd.exp @@ -54,8 +54,10 @@ mi_gdb_test "-pycmd ary" \ "\\^done,result=3D\\\[\"Hello\",\"42\"\\\]" \ "-pycmd ary" =20 +set re_order1 "\\^done,result=3D{hello=3D\"world\",times=3D\"42\"}" +set re_order2 "\\^done,result=3D{times=3D\"42\",hello=3D\"world\"}" mi_gdb_test "-pycmd dct" \ - "\\^done,result=3D{hello=3D\"world\",times=3D\"42\"}" \ + "($re_order1|$re_order2)" \ "-pycmd dct" =20 mi_gdb_test "-pycmd bk1" \