From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MGxtBRQap2Kp0wEAWB0awg (envelope-from ) for ; Mon, 13 Jun 2022 07:05:56 -0400 Received: by simark.ca (Postfix, from userid 112) id 067C91E224; Mon, 13 Jun 2022 07:05:56 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=qLnu44ZA; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 9ED961E143 for ; Mon, 13 Jun 2022 07:05:55 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0E8B2382CF21 for ; Mon, 13 Jun 2022 11:05:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0E8B2382CF21 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1655118355; bh=p2VsfjGWi4lnaWlImSDm8vKtDmaDb9SoF9c/TAU0Q9Q=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=qLnu44ZAcixl5BqEQWAkIok75q4pGb/knZmU75nCUrhSLBS5Zy0cIJFVrHGfuSy2t SvS4eA+TQ8w/8XdCGqvQxklEwF+6I47lK5F+CD1FutjCCxpwp4TcxCzS1GNnUjuBkE 0qldxqvCxPwRyg8+SciNRc3+fsCglGDnBAqJp5QI= Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 09B64385043E for ; Mon, 13 Jun 2022 11:05:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 09B64385043E Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3FEB821D2D; Mon, 13 Jun 2022 11:05:35 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 28AB3134CF; Mon, 13 Jun 2022 11:05:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id tCPVCP8Zp2LYbgAAMHmgww (envelope-from ); Mon, 13 Jun 2022 11:05:35 +0000 Date: Mon, 13 Jun 2022 13:05:33 +0200 To: gdb-patches@sourceware.org Subject: [PATCH][gdb/testsuite] Handle unordered dict in gdb.python/py-mi-cmd.exp Message-ID: <20220613110532.GA27620@delia.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Cc: Andrew Burgess Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi, When running test-case gdb.python/py-mi-cmd.exp on openSUSE Leap 42.3 with python 3.4, I occasionally run into: ... Expecting: ^(-pycmd dct[^M ]+)?(\^done,result={hello="world",times="42"}[^M ]+[(]gdb[)] ^M [ ]*) -pycmd dct^M ^done,result={times="42",hello="world"}^M (gdb) ^M FAIL: gdb.python/py-mi-cmd.exp: -pycmd dct (unexpected output) ... The problem is that the data type used here in py-mi-cmd.py: ... elif argv[0] == "dct": return {"result": {"hello": "world", "times": 42}} ... is a dictionary, and only starting version 3.6 are dictionaries insertion ordered, so using PyDict_Next in serialize_mi_result doesn't guarantee a fixed order. Fix this by allowing the alternative order. Tested on x86_64-linux. Any comments? Thanks, - Tom [gdb/testsuite] Handle unordered dict in gdb.python/py-mi-cmd.exp --- 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.python/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=\\\[\"Hello\",\"42\"\\\]" \ "-pycmd ary" +set re_order1 "\\^done,result={hello=\"world\",times=\"42\"}" +set re_order2 "\\^done,result={times=\"42\",hello=\"world\"}" mi_gdb_test "-pycmd dct" \ - "\\^done,result={hello=\"world\",times=\"42\"}" \ + "($re_order1|$re_order2)" \ "-pycmd dct" mi_gdb_test "-pycmd bk1" \