From nobody Mon Feb 9 16:00:53 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608049588; cv=none; d=zohomail.com; s=zohoarc; b=PDCCoyFsUabzZ9MSJiMJ9RFAkt5hDXIn77nQVnX0YT8hmMXu/Ui6U6IBb6KvSCojWtjUGsjPvPD8JHcB7HARNgVbAYjLk6aqGftjDwRZTzSNQFG6NlkwMaPTEIJ0BOD3bvQkEPn1iuOj1FBNB0FuLzai6BmFWAU9fTBAuk+C7H4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608049588; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uPYTqmZl1uMZwqQEY2buTyK6t0ccFliq9VUI7hF/mfQ=; b=lukfrn//MvPEccfXQmoRIaPlA2Yk9ZPPinI+5mdwofGcQPscaXZ3CIqwU8Oft43CHutkVUZUFkXIe+PTjKOxS+scULTnds2i5egBk8w3a4ZX2xZrNzMiFH/5usWnounZx2BBJSZ9crP1JUSgWpWDsPMf7wbCQVuCKGj1r2i6WJQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1608049587938436.82734684738523; Tue, 15 Dec 2020 08:26:27 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-429-1zpDpM9VOgivhUjeCus8Hg-1; Tue, 15 Dec 2020 11:26:03 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 73307100A254; Tue, 15 Dec 2020 16:25:47 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 35CA87444C; Tue, 15 Dec 2020 16:25:47 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E514F5002F; Tue, 15 Dec 2020 16:25:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BFGPfcK025825 for ; Tue, 15 Dec 2020 11:25:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id 420565D9E4; Tue, 15 Dec 2020 16:25:41 +0000 (UTC) Received: from work.redhat.com (ovpn-114-20.ams2.redhat.com [10.36.114.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74A835D9D7; Tue, 15 Dec 2020 16:25:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608049582; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=uPYTqmZl1uMZwqQEY2buTyK6t0ccFliq9VUI7hF/mfQ=; b=eI+osu6OsGsX9lrX4Dam79k3fm5Y21YiDXugkydnKZ8iHEnCA0FblDLTiuXm4MtUY8jFtf 4c9SnWNDOgV33BEju2kKb6NOMRCpKs7sGms6OT5PWz/LwV5ZGFr/nDTNZbFI5MSTMez3CX maLfW0LSgmByhF9eAaeFjkvwaEnnJwU= X-MC-Unique: 1zpDpM9VOgivhUjeCus8Hg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 21/29] cpu-parse: Move json output to new script Date: Tue, 15 Dec 2020 17:25:07 +0100 Message-Id: <20201215162515.53742-22-twiederh@redhat.com> In-Reply-To: <20201215162515.53742-1-twiederh@redhat.com> References: <20201215162515.53742-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake --- tests/cputestdata/cpu-gather.py | 30 ++++++++++++++++++++++++++++++ tests/cputestdata/cpu-parse.sh | 16 ---------------- tests/cputestdata/cpu-reformat.py | 9 --------- 3 files changed, 30 insertions(+), 25 deletions(-) delete mode 100755 tests/cputestdata/cpu-reformat.py diff --git a/tests/cputestdata/cpu-gather.py b/tests/cputestdata/cpu-gather= .py index bc5c7dbb15..2c3f39ab35 100755 --- a/tests/cputestdata/cpu-gather.py +++ b/tests/cputestdata/cpu-gather.py @@ -244,13 +244,43 @@ def output_xml(data, filename): f.write("\n") =20 =20 +def output_json(data, filename): + replies =3D list() + for reply in data["model"]: + if "QMP" in reply: + continue + if "timestamp" in reply: + continue + if "return" in reply and not reply["return"]: + continue + replies.append(reply) + + if not replies: + return + + if "model-expansion" not in [reply.get("id") for reply in replies]: + exit( + "Error: Missing query-cpu-model-expansion reply in " + "{}".format(filename)) + + print(filename) + with open(filename, "wt") as f: + for reply in replies: + if reply is not replies[0]: + f.write("\n") + json.dump(reply, f, indent=3D2) + f.write("\n") + + def parse(args): data =3D json.load(sys.stdin) =20 filename =3D parse_filename(data) filename_xml =3D "{}.xml".format(filename) + filename_json =3D "{}.json".format(filename) =20 output_xml(data, filename_xml) + output_json(data, filename_json) =20 os.environ["CPU_GATHER_PY"] =3D "true" os.environ["model"] =3D data["name"] diff --git a/tests/cputestdata/cpu-parse.sh b/tests/cputestdata/cpu-parse.sh index 84d37d0df4..aeb6e4e07f 100755 --- a/tests/cputestdata/cpu-parse.sh +++ b/tests/cputestdata/cpu-parse.sh @@ -7,23 +7,7 @@ fi =20 data=3D`cat` =20 -json() -{ - first=3Dtrue - sed -ne '/{"QMP".*/d; - /{"return": {}}/d; - /{"timestamp":.*/d; - /^{/p' <<<"$data" | \ - while read; do - $first || echo - first=3Dfalse - $(dirname $0)/cpu-reformat.py <<<"$REPLY" - done -} - -json <<<"$data" >$fname.json if [[ -s $fname.json ]]; then - echo $fname.json if ! grep -q model-expansion $fname.json; then echo "Missing query-cpu-model-expansion reply in $name.json" >&2 exit 1 diff --git a/tests/cputestdata/cpu-reformat.py b/tests/cputestdata/cpu-refo= rmat.py deleted file mode 100755 index fcc6b8ab41..0000000000 --- a/tests/cputestdata/cpu-reformat.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import json - -dec =3D json.JSONDecoder() -data, pos =3D dec.raw_decode(sys.stdin.read()) -json.dump(data, sys.stdout, indent=3D2, separators=3D(',', ': ')) -print("") --=20 2.26.2