From nobody Sat Nov 23 17:30:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1723672417143938.3550366619363; Wed, 14 Aug 2024 14:53:37 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1E67B12A3; Wed, 14 Aug 2024 17:53:36 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 84345141F; Wed, 14 Aug 2024 17:43:26 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 3C4C81361; Wed, 14 Aug 2024 17:43:20 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id C255512E4 for ; Wed, 14 Aug 2024 17:43:12 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-346-Gq9AlaM3OEaEg_lSC1NNbA-1; Wed, 14 Aug 2024 17:43:11 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3FEA91944D24 for ; Wed, 14 Aug 2024 21:43:10 +0000 (UTC) Received: from hjs.brq.redhat.com (unknown [10.43.3.187]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8B2C41955E8C for ; Wed, 14 Aug 2024 21:43:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723671792; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YcSYL8IQH+seBqj0+yjMCk7AWeCQ/xrQk48/ZUnEkrc=; b=bNHLaSKegrtFYmQIAmEtp1iwhMFhlVIsV2yEc+qelkxxB3r5+P2z2Hfkw8B04puCc2V++o Yt3aqjqi70N25h888r4krK9ETVqD1ZQ2BvvqrwwOQZkblw30ZqtokLpOapbFSlHbvPAEzq dc0zUjCvIyNJn69ajCx85i2LoUETaCY= X-MC-Unique: Gq9AlaM3OEaEg_lSC1NNbA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: devel@lists.libvirt.org Subject: [libvirt PATCH 04/20] tests: switch to compact empty JSON object formatting Date: Wed, 14 Aug 2024 23:40:19 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: CLHCQFJN2SU7N6GKMBNXQ5JHROYXMZFG X-Message-ID-Hash: CLHCQFJN2SU7N6GKMBNXQ5JHROYXMZFG X-MailFrom: jtomko@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1723672418269116600 Content-Type: text/plain; charset="utf-8" Some earlier versions of json-c format empty elements differently. Run the tests who use the pretty formatting for readability and diffability through a function that unifies the output. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- tests/qemublocktest.c | 5 ++++- tests/qemublocktestdata/backupmerge/empty-out.json | 4 +--- tests/qemumigparamsdata/empty.json | 4 +--- tests/qemumigparamstest.c | 5 ++++- tests/virmacmaptest.c | 5 ++++- tests/virmacmaptestdata/empty.json | 4 +--- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index c581bd1748..6c4e735466 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -720,6 +720,7 @@ testQemuBackupIncrementalBitmapCalculate(const void *op= aque) g_autofree char *expectpath =3D NULL; g_autoptr(virStorageSource) target =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + g_autofree char *actual =3D NULL; =20 expectpath =3D g_strdup_printf("%s/%s%s-out.json", abs_srcdir, backupDataPrefix, data->name); @@ -748,7 +749,9 @@ testQemuBackupIncrementalBitmapCalculate(const void *op= aque) virBufferAddLit(&buf, "NULL\n"); } =20 - return virTestCompareToFile(virBufferCurrentContent(&buf), expectpath); + actual =3D virJSONStringPrettifyBlanks(virBufferCurrentContent(&buf)); + + return virTestCompareToFile(actual, expectpath); } =20 =20 diff --git a/tests/qemublocktestdata/backupmerge/empty-out.json b/tests/qem= ublocktestdata/backupmerge/empty-out.json index 41b42e677b..fe51488c70 100644 --- a/tests/qemublocktestdata/backupmerge/empty-out.json +++ b/tests/qemublocktestdata/backupmerge/empty-out.json @@ -1,3 +1 @@ -[ - -] +[] diff --git a/tests/qemumigparamsdata/empty.json b/tests/qemumigparamsdata/e= mpty.json index 0db3279e44..0967ef424b 100644 --- a/tests/qemumigparamsdata/empty.json +++ b/tests/qemumigparamsdata/empty.json @@ -1,3 +1 @@ -{ - -} +{} diff --git a/tests/qemumigparamstest.c b/tests/qemumigparamstest.c index 5d45a9dd58..67cc14d948 100644 --- a/tests/qemumigparamstest.c +++ b/tests/qemumigparamstest.c @@ -137,6 +137,7 @@ qemuMigParamsTestJSON(const void *opaque) g_autoptr(virJSONValue) paramsIn =3D NULL; g_autoptr(virJSONValue) paramsOut =3D NULL; g_autoptr(qemuMigrationParams) migParams =3D NULL; + g_autofree char *formattedJSON =3D NULL; g_autofree char *actualJSON =3D NULL; g_auto(virBuffer) debug =3D VIR_BUFFER_INITIALIZER; =20 @@ -156,9 +157,11 @@ qemuMigParamsTestJSON(const void *opaque) return -1; =20 if (!(paramsOut =3D qemuMigrationParamsToJSON(migParams, false)) || - !(actualJSON =3D virJSONValueToString(paramsOut, true))) + !(formattedJSON =3D virJSONValueToString(paramsOut, true))) return -1; =20 + actualJSON =3D virJSONStringPrettifyBlanks(formattedJSON); + if (testQEMUSchemaValidateCommand("migrate-set-parameters", paramsOut, data->qmpschema, diff --git a/tests/virmacmaptest.c b/tests/virmacmaptest.c index 9a28c1bed0..074bc8f659 100644 --- a/tests/virmacmaptest.c +++ b/tests/virmacmaptest.c @@ -118,13 +118,16 @@ testMACFlush(const void *opaque) const struct testData *data =3D opaque; g_autofree char *file =3D NULL; g_autofree char *str =3D NULL; + g_autofree char *actual =3D NULL; =20 file =3D g_strdup_printf("%s/virmacmaptestdata/%s.json", abs_srcdir, d= ata->file); =20 if (virMacMapDumpStr(data->mgr, &str) < 0) return -1; =20 - if (virTestCompareToFile(str, file) < 0) + actual =3D virJSONStringPrettifyBlanks(str); + + if (virTestCompareToFile(actual, file) < 0) return -1; =20 return 0; diff --git a/tests/virmacmaptestdata/empty.json b/tests/virmacmaptestdata/e= mpty.json index 41b42e677b..fe51488c70 100644 --- a/tests/virmacmaptestdata/empty.json +++ b/tests/virmacmaptestdata/empty.json @@ -1,3 +1 @@ -[ - -] +[] --=20 2.45.2