From nobody Sun May 5 06:41:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554219792582844.6182371027384; Tue, 2 Apr 2019 08:43:12 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A3C6E356F6; Tue, 2 Apr 2019 15:43:00 +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 C64A25D78F; Tue, 2 Apr 2019 15:42:56 +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 BE0A741F3C; Tue, 2 Apr 2019 15:42:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x32Fg1uG011830 for ; Tue, 2 Apr 2019 11:42:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id A77BE5C21A; Tue, 2 Apr 2019 15:42:01 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F6CA5C6A5 for ; Tue, 2 Apr 2019 15:41:59 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 2 Apr 2019 17:41:40 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCHv2 01/14] virjsontest: switch AddAndRemove tests to work with files 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 02 Apr 2019 15:43:06 +0000 (UTC) Instead of using JSON in C strings, put it in separate files for easier manipulation. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Andrea Bolognani --- tests/virjsondata/add-remove-failure-in.json | 1 + tests/virjsondata/add-remove-success-in.json | 1 + tests/virjsondata/add-remove-success-out.json | 1 + tests/virjsontest.c | 38 ++++++++++++------- 4 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 tests/virjsondata/add-remove-failure-in.json create mode 100644 tests/virjsondata/add-remove-success-in.json create mode 100644 tests/virjsondata/add-remove-success-out.json diff --git a/tests/virjsondata/add-remove-failure-in.json b/tests/virjsonda= ta/add-remove-failure-in.json new file mode 100644 index 0000000000..dd264421e9 --- /dev/null +++ b/tests/virjsondata/add-remove-failure-in.json @@ -0,0 +1 @@ +[ 1 ] diff --git a/tests/virjsondata/add-remove-success-in.json b/tests/virjsonda= ta/add-remove-success-in.json new file mode 100644 index 0000000000..b8edd30963 --- /dev/null +++ b/tests/virjsondata/add-remove-success-in.json @@ -0,0 +1 @@ +{"name": "sample", "value": true} diff --git a/tests/virjsondata/add-remove-success-out.json b/tests/virjsond= ata/add-remove-success-out.json new file mode 100644 index 0000000000..9f1e44637c --- /dev/null +++ b/tests/virjsondata/add-remove-success-out.json @@ -0,0 +1 @@ +{"value":true,"newname":"foo"} diff --git a/tests/virjsontest.c b/tests/virjsontest.c index a4bd4fb07b..429eb58704 100644 --- a/tests/virjsontest.c +++ b/tests/virjsontest.c @@ -68,12 +68,24 @@ static int testJSONAddRemove(const void *data) { const struct testInfo *info =3D data; - virJSONValuePtr json; + virJSONValuePtr json =3D NULL; virJSONValuePtr name =3D NULL; - char *result =3D NULL; + char *infile =3D NULL; + char *indata =3D NULL; + char *outfile =3D NULL; + char *actual =3D NULL; int ret =3D -1; =20 - json =3D virJSONValueFromString(info->doc); + if (virAsprintf(&infile, "%s/virjsondata/add-remove-%s-in.json", + abs_srcdir, info->name) < 0 || + virAsprintf(&outfile, "%s/virjsondata/add-remove-%s-out.json", + abs_srcdir, info->name) < 0) + goto cleanup; + + if (virTestLoadFile(infile, &indata) < 0) + goto cleanup; + + json =3D virJSONValueFromString(indata); if (!json) { VIR_TEST_VERBOSE("Fail to parse %s\n", info->name); ret =3D -1; @@ -113,20 +125,22 @@ testJSONAddRemove(const void *data) VIR_TEST_VERBOSE("%s", "unexpected failure adding new key\n"); goto cleanup; } - if (!(result =3D virJSONValueToString(json, false))) { + if (!(actual =3D virJSONValueToString(json, false))) { VIR_TEST_VERBOSE("%s", "failed to stringize result\n"); goto cleanup; } - if (STRNEQ(info->expect, result)) { - virTestDifference(stderr, info->expect, result); + if (virTestCompareToFile(actual, outfile) < 0) goto cleanup; - } + ret =3D 0; =20 cleanup: virJSONValueFree(json); virJSONValueFree(name); - VIR_FREE(result); + VIR_FREE(infile); + VIR_FREE(indata); + VIR_FREE(outfile); + VIR_FREE(actual); return ret; } =20 @@ -543,12 +557,8 @@ mymain(void) "\"query-uuid\"},{\"name\":\"query-migrate\"},{\"name\":" "\"query-balloon\"}],\"id\":\"libvirt-2\"}", NULL); =20 - DO_TEST_FULL("add and remove", AddRemove, - "{\"name\": \"sample\", \"value\": true}", - "{\"value\":true,\"newname\":\"foo\"}", - true); - DO_TEST_FULL("add and remove", AddRemove, - "[ 1 ]", NULL, false); + DO_TEST_FULL("success", AddRemove, NULL, NULL, true); + DO_TEST_FULL("failure", AddRemove, NULL, NULL, false); =20 DO_TEST_FULL("copy and free", Copy, "{\"return\": [{\"name\": \"quit\"}, {\"name\": \"eject\"= }," --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 06:41:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554219808944354.8624803593186; Tue, 2 Apr 2019 08:43:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1CBF681DF6; Tue, 2 Apr 2019 15:43:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B008362A14; Tue, 2 Apr 2019 15:43:23 +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 3D776180338C; Tue, 2 Apr 2019 15:43:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x32Fg2sl011836 for ; Tue, 2 Apr 2019 11:42:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7B3165C21A; Tue, 2 Apr 2019 15:42:02 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 005855C237 for ; Tue, 2 Apr 2019 15:42:01 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 2 Apr 2019 17:41:41 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCHv2 02/14] testJSONFromString: regroup if blocks 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 02 Apr 2019 15:43:28 +0000 (UTC) Handle failure to parse the JSON in an else branch for readability. Signed-off-by: J=C3=A1n Tomko --- tests/virjsontest.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/virjsontest.c b/tests/virjsontest.c index 429eb58704..3c4bb4141a 100644 --- a/tests/virjsontest.c +++ b/tests/virjsontest.c @@ -36,11 +36,11 @@ testJSONFromString(const void *data) ret =3D 0; goto cleanup; } - } - - if (!info->pass) { - VIR_TEST_VERBOSE("Should not have parsed %s\n", info->doc); - goto cleanup; + } else { + if (!info->pass) { + VIR_TEST_VERBOSE("Should not have parsed %s\n", info->name); + goto cleanup; + } } =20 VIR_TEST_DEBUG("Parsed %s\n", info->doc); --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 06:41:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554219790561547.4564214123949; Tue, 2 Apr 2019 08:43:10 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 688BEC4EBD; Tue, 2 Apr 2019 15:43:09 +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 3E97C194B8; Tue, 2 Apr 2019 15:43:09 +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 7A29F4EA65; Tue, 2 Apr 2019 15:43:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x32Fg3gV011849 for ; Tue, 2 Apr 2019 11:42:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 513475C237; Tue, 2 Apr 2019 15:42:03 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC6AD5C21A for ; Tue, 2 Apr 2019 15:42:02 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 2 Apr 2019 17:41:42 +0200 Message-Id: <56ea30d1e332ef8ad6e989303980a005d41c675a.1554219669.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCHv2 03/14] virjsontest: reword error messages in testJSONFromString 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 02 Apr 2019 15:43:09 +0000 (UTC) Signed-off-by: J=C3=A1n Tomko --- tests/virjsontest.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/virjsontest.c b/tests/virjsontest.c index 3c4bb4141a..51777ba770 100644 --- a/tests/virjsontest.c +++ b/tests/virjsontest.c @@ -29,16 +29,16 @@ testJSONFromString(const void *data) =20 if (!json) { if (info->pass) { - VIR_TEST_VERBOSE("Fail to parse %s\n", info->doc); + VIR_TEST_VERBOSE("Failed to parse %s\n", info->doc); goto cleanup; } else { - VIR_TEST_DEBUG("Fail to parse %s\n", info->doc); + VIR_TEST_DEBUG("As expected, failed to parse %s\n", info->doc); ret =3D 0; goto cleanup; } } else { if (!info->pass) { - VIR_TEST_VERBOSE("Should not have parsed %s\n", info->name); + VIR_TEST_VERBOSE("Unexpected success while parsing %s\n", info= ->doc); goto cleanup; } } --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 06:41:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554219802740175.66968356071584; Tue, 2 Apr 2019 08:43:22 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 54EEEC04FFF6; Tue, 2 Apr 2019 15:43:20 +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 D57631001E6D; Tue, 2 Apr 2019 15:43:19 +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 7ECA14EA7A; Tue, 2 Apr 2019 15:43:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x32Fg6df011862 for ; Tue, 2 Apr 2019 11:42:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 19D145C21A; Tue, 2 Apr 2019 15:42:06 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 969AD173F4 for ; Tue, 2 Apr 2019 15:42:03 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 2 Apr 2019 17:41:43 +0200 Message-Id: <3cb6335abc0d575c3a817c613077e576b539c537.1554219669.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCHv2 04/14] virjsontest: use VIR_AUTOPTR for virJSONValues 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 02 Apr 2019 15:43:20 +0000 (UTC) Remove all explicit usage of virJSONValueFree. Signed-off-by: J=C3=A1n Tomko --- tests/virjsontest.c | 45 +++++++++++++++------------------------------ 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/tests/virjsontest.c b/tests/virjsontest.c index 51777ba770..bf2bb85c6c 100644 --- a/tests/virjsontest.c +++ b/tests/virjsontest.c @@ -20,7 +20,7 @@ static int testJSONFromString(const void *data) { const struct testInfo *info =3D data; - virJSONValuePtr json; + VIR_AUTOPTR(virJSONValue) json =3D NULL; const char *expectstr =3D info->expect ? info->expect : info->doc; char *formatted =3D NULL; int ret =3D -1; @@ -59,7 +59,6 @@ testJSONFromString(const void *data) =20 cleanup: VIR_FREE(formatted); - virJSONValueFree(json); return ret; } =20 @@ -68,8 +67,8 @@ static int testJSONAddRemove(const void *data) { const struct testInfo *info =3D data; - virJSONValuePtr json =3D NULL; - virJSONValuePtr name =3D NULL; + VIR_AUTOPTR(virJSONValue) json =3D NULL; + VIR_AUTOPTR(virJSONValue) name =3D NULL; char *infile =3D NULL; char *indata =3D NULL; char *outfile =3D NULL; @@ -135,8 +134,6 @@ testJSONAddRemove(const void *data) ret =3D 0; =20 cleanup: - virJSONValueFree(json); - virJSONValueFree(name); VIR_FREE(infile); VIR_FREE(indata); VIR_FREE(outfile); @@ -149,7 +146,7 @@ static int testJSONLookup(const void *data) { const struct testInfo *info =3D data; - virJSONValuePtr json; + VIR_AUTOPTR(virJSONValue) json =3D NULL; virJSONValuePtr value =3D NULL; char *result =3D NULL; int rc; @@ -247,7 +244,6 @@ testJSONLookup(const void *data) ret =3D 0; =20 cleanup: - virJSONValueFree(json); VIR_FREE(result); return ret; } @@ -257,8 +253,8 @@ static int testJSONCopy(const void *data) { const struct testInfo *info =3D data; - virJSONValuePtr json =3D NULL; - virJSONValuePtr jsonCopy =3D NULL; + VIR_AUTOPTR(virJSONValue) json =3D NULL; + VIR_AUTOPTR(virJSONValue) jsonCopy =3D NULL; char *result =3D NULL; char *resultCopy =3D NULL; int ret =3D -1; @@ -318,8 +314,6 @@ testJSONCopy(const void *data) cleanup: VIR_FREE(result); VIR_FREE(resultCopy); - virJSONValueFree(json); - virJSONValueFree(jsonCopy); return ret; } =20 @@ -328,8 +322,8 @@ static int testJSONDeflatten(const void *data) { const struct testInfo *info =3D data; - virJSONValuePtr injson =3D NULL; - virJSONValuePtr deflattened =3D NULL; + VIR_AUTOPTR(virJSONValue) injson =3D NULL; + VIR_AUTOPTR(virJSONValue) deflattened =3D NULL; char *infile =3D NULL; char *indata =3D NULL; char *outfile =3D NULL; @@ -369,8 +363,6 @@ testJSONDeflatten(const void *data) ret =3D 0; =20 cleanup: - virJSONValueFree(injson); - virJSONValueFree(deflattened); VIR_FREE(infile); VIR_FREE(indata); VIR_FREE(outfile); @@ -383,9 +375,9 @@ testJSONDeflatten(const void *data) static int testJSONEscapeObj(const void *data ATTRIBUTE_UNUSED) { - virJSONValuePtr json =3D NULL; - virJSONValuePtr nestjson =3D NULL; - virJSONValuePtr parsejson =3D NULL; + VIR_AUTOPTR(virJSONValue) json =3D NULL; + VIR_AUTOPTR(virJSONValue) nestjson =3D NULL; + VIR_AUTOPTR(virJSONValue) parsejson =3D NULL; char *neststr =3D NULL; char *result =3D NULL; const char *parsednestedstr; @@ -434,9 +426,6 @@ testJSONEscapeObj(const void *data ATTRIBUTE_UNUSED) cleanup: VIR_FREE(neststr); VIR_FREE(result); - virJSONValueFree(json); - virJSONValueFree(nestjson); - virJSONValueFree(parsejson); return ret; } =20 @@ -444,10 +433,10 @@ testJSONEscapeObj(const void *data ATTRIBUTE_UNUSED) static int testJSONObjectFormatSteal(const void *opaque ATTRIBUTE_UNUSED) { - virJSONValuePtr a1 =3D NULL; - virJSONValuePtr a2 =3D NULL; - virJSONValuePtr t1 =3D NULL; - virJSONValuePtr t2 =3D NULL; + VIR_AUTOPTR(virJSONValue) a1 =3D NULL; + VIR_AUTOPTR(virJSONValue) a2 =3D NULL; + VIR_AUTOPTR(virJSONValue) t1 =3D NULL; + VIR_AUTOPTR(virJSONValue) t2 =3D NULL; int ret =3D -1; =20 if (!(a1 =3D virJSONValueNewString("test")) || @@ -478,10 +467,6 @@ testJSONObjectFormatSteal(const void *opaque ATTRIBUTE= _UNUSED) ret =3D 0; =20 cleanup: - virJSONValueFree(a1); - virJSONValueFree(a2); - virJSONValueFree(t1); - virJSONValueFree(t2); return ret; } =20 --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 06:41:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554219810978619.4473723303473; Tue, 2 Apr 2019 08:43:30 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B521A3688B; Tue, 2 Apr 2019 15:43:29 +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 8A6701815D; Tue, 2 Apr 2019 15:43:29 +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 400234ED28; Tue, 2 Apr 2019 15:43:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x32FgBuN011872 for ; Tue, 2 Apr 2019 11:42:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 36C895C21A; Tue, 2 Apr 2019 15:42:11 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2E271724D for ; Tue, 2 Apr 2019 15:42:06 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 2 Apr 2019 17:41:44 +0200 Message-Id: <5eb543fd7e514b9a5b247975c5601fd39551b23e.1554219669.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCHv2 05/14] virjsontest: use VIR_AUTOFREE for strings 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 02 Apr 2019 15:43:30 +0000 (UTC) The only remaining use of VIR_FREE is for reusing variables. Signed-off-by: J=C3=A1n Tomko --- tests/virjsontest.c | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/tests/virjsontest.c b/tests/virjsontest.c index bf2bb85c6c..12458878e0 100644 --- a/tests/virjsontest.c +++ b/tests/virjsontest.c @@ -22,7 +22,7 @@ testJSONFromString(const void *data) const struct testInfo *info =3D data; VIR_AUTOPTR(virJSONValue) json =3D NULL; const char *expectstr =3D info->expect ? info->expect : info->doc; - char *formatted =3D NULL; + VIR_AUTOFREE(char *) formatted =3D NULL; int ret =3D -1; =20 json =3D virJSONValueFromString(info->doc); @@ -58,7 +58,6 @@ testJSONFromString(const void *data) ret =3D 0; =20 cleanup: - VIR_FREE(formatted); return ret; } =20 @@ -69,10 +68,10 @@ testJSONAddRemove(const void *data) const struct testInfo *info =3D data; VIR_AUTOPTR(virJSONValue) json =3D NULL; VIR_AUTOPTR(virJSONValue) name =3D NULL; - char *infile =3D NULL; - char *indata =3D NULL; - char *outfile =3D NULL; - char *actual =3D NULL; + VIR_AUTOFREE(char *) infile =3D NULL; + VIR_AUTOFREE(char *) indata =3D NULL; + VIR_AUTOFREE(char *) outfile =3D NULL; + VIR_AUTOFREE(char *) actual =3D NULL; int ret =3D -1; =20 if (virAsprintf(&infile, "%s/virjsondata/add-remove-%s-in.json", @@ -134,10 +133,6 @@ testJSONAddRemove(const void *data) ret =3D 0; =20 cleanup: - VIR_FREE(infile); - VIR_FREE(indata); - VIR_FREE(outfile); - VIR_FREE(actual); return ret; } =20 @@ -148,7 +143,7 @@ testJSONLookup(const void *data) const struct testInfo *info =3D data; VIR_AUTOPTR(virJSONValue) json =3D NULL; virJSONValuePtr value =3D NULL; - char *result =3D NULL; + VIR_AUTOFREE(char *) result =3D NULL; int rc; int number; const char *str; @@ -244,7 +239,6 @@ testJSONLookup(const void *data) ret =3D 0; =20 cleanup: - VIR_FREE(result); return ret; } =20 @@ -255,8 +249,8 @@ testJSONCopy(const void *data) const struct testInfo *info =3D data; VIR_AUTOPTR(virJSONValue) json =3D NULL; VIR_AUTOPTR(virJSONValue) jsonCopy =3D NULL; - char *result =3D NULL; - char *resultCopy =3D NULL; + VIR_AUTOFREE(char *) result =3D NULL; + VIR_AUTOFREE(char *) resultCopy =3D NULL; int ret =3D -1; =20 json =3D virJSONValueFromString(info->doc); @@ -312,8 +306,6 @@ testJSONCopy(const void *data) =20 ret =3D 0; cleanup: - VIR_FREE(result); - VIR_FREE(resultCopy); return ret; } =20 @@ -324,10 +316,10 @@ testJSONDeflatten(const void *data) const struct testInfo *info =3D data; VIR_AUTOPTR(virJSONValue) injson =3D NULL; VIR_AUTOPTR(virJSONValue) deflattened =3D NULL; - char *infile =3D NULL; - char *indata =3D NULL; - char *outfile =3D NULL; - char *actual =3D NULL; + VIR_AUTOFREE(char *) infile =3D NULL; + VIR_AUTOFREE(char *) indata =3D NULL; + VIR_AUTOFREE(char *) outfile =3D NULL; + VIR_AUTOFREE(char *) actual =3D NULL; int ret =3D -1; =20 if (virAsprintf(&infile, "%s/virjsondata/deflatten-%s-in.json", @@ -363,10 +355,6 @@ testJSONDeflatten(const void *data) ret =3D 0; =20 cleanup: - VIR_FREE(infile); - VIR_FREE(indata); - VIR_FREE(outfile); - VIR_FREE(actual); =20 return ret; } @@ -378,8 +366,8 @@ testJSONEscapeObj(const void *data ATTRIBUTE_UNUSED) VIR_AUTOPTR(virJSONValue) json =3D NULL; VIR_AUTOPTR(virJSONValue) nestjson =3D NULL; VIR_AUTOPTR(virJSONValue) parsejson =3D NULL; - char *neststr =3D NULL; - char *result =3D NULL; + VIR_AUTOFREE(char *) neststr =3D NULL; + VIR_AUTOFREE(char *) result =3D NULL; const char *parsednestedstr; int ret =3D -1; =20 @@ -424,8 +412,6 @@ testJSONEscapeObj(const void *data ATTRIBUTE_UNUSED) ret =3D 0; =20 cleanup: - VIR_FREE(neststr); - VIR_FREE(result); return ret; } =20 --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 06:41:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554219827793335.0625736224574; Tue, 2 Apr 2019 08:43:47 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6D12A5947B; Tue, 2 Apr 2019 15:43:46 +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 45D0A6248C; Tue, 2 Apr 2019 15:43:46 +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 066754EDDB; Tue, 2 Apr 2019 15:43:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x32FgCgO011877 for ; Tue, 2 Apr 2019 11:42:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0860F5C237; Tue, 2 Apr 2019 15:42:12 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 839285C21A for ; Tue, 2 Apr 2019 15:42:11 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 2 Apr 2019 17:41:45 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCHv2 06/14] virjsontest: remove unnecessary cleanup labels 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 02 Apr 2019 15:43:47 +0000 (UTC) Now that cleanup is handled automatically, we can use 'return' more often. Signed-off-by: J=C3=A1n Tomko --- tests/virjsontest.c | 160 ++++++++++++++++++-------------------------- 1 file changed, 65 insertions(+), 95 deletions(-) diff --git a/tests/virjsontest.c b/tests/virjsontest.c index 12458878e0..0825a87188 100644 --- a/tests/virjsontest.c +++ b/tests/virjsontest.c @@ -23,23 +23,21 @@ testJSONFromString(const void *data) VIR_AUTOPTR(virJSONValue) json =3D NULL; const char *expectstr =3D info->expect ? info->expect : info->doc; VIR_AUTOFREE(char *) formatted =3D NULL; - int ret =3D -1; =20 json =3D virJSONValueFromString(info->doc); =20 if (!json) { if (info->pass) { VIR_TEST_VERBOSE("Failed to parse %s\n", info->doc); - goto cleanup; + return -1; } else { VIR_TEST_DEBUG("As expected, failed to parse %s\n", info->doc); - ret =3D 0; - goto cleanup; + return 0; } } else { if (!info->pass) { VIR_TEST_VERBOSE("Unexpected success while parsing %s\n", info= ->doc); - goto cleanup; + return -1; } } =20 @@ -47,18 +45,15 @@ testJSONFromString(const void *data) =20 if (!(formatted =3D virJSONValueToString(json, false))) { VIR_TEST_VERBOSE("Failed to format json data\n"); - goto cleanup; + return -1; } =20 if (STRNEQ(expectstr, formatted)) { virTestDifference(stderr, expectstr, formatted); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -72,22 +67,20 @@ testJSONAddRemove(const void *data) VIR_AUTOFREE(char *) indata =3D NULL; VIR_AUTOFREE(char *) outfile =3D NULL; VIR_AUTOFREE(char *) actual =3D NULL; - int ret =3D -1; =20 if (virAsprintf(&infile, "%s/virjsondata/add-remove-%s-in.json", abs_srcdir, info->name) < 0 || virAsprintf(&outfile, "%s/virjsondata/add-remove-%s-out.json", abs_srcdir, info->name) < 0) - goto cleanup; + return -1; =20 if (virTestLoadFile(infile, &indata) < 0) - goto cleanup; + return -1; =20 json =3D virJSONValueFromString(indata); if (!json) { VIR_TEST_VERBOSE("Fail to parse %s\n", info->name); - ret =3D -1; - goto cleanup; + return -1; } =20 switch (virJSONValueObjectRemoveKey(json, "name", &name)) { @@ -95,45 +88,43 @@ testJSONAddRemove(const void *data) if (!info->pass) { VIR_TEST_VERBOSE("should not remove from non-object %s\n", info->name); - goto cleanup; + return -1; } break; case -1: if (!info->pass) - ret =3D 0; + return 0; else VIR_TEST_VERBOSE("Fail to recognize non-object %s\n", info->na= me); - goto cleanup; + return -1; default: VIR_TEST_VERBOSE("unexpected result when removing from %s\n", info->name); - goto cleanup; + return -1; } if (STRNEQ_NULLABLE(virJSONValueGetString(name), "sample")) { VIR_TEST_VERBOSE("unexpected value after removing name: %s\n", NULLSTR(virJSONValueGetString(name))); - goto cleanup; + return -1; } if (virJSONValueObjectRemoveKey(json, "name", NULL)) { VIR_TEST_VERBOSE("%s", "unexpected success when removing missing key\n"); - goto cleanup; + return -1; } if (virJSONValueObjectAppendString(json, "newname", "foo") < 0) { VIR_TEST_VERBOSE("%s", "unexpected failure adding new key\n"); - goto cleanup; + return -1; } if (!(actual =3D virJSONValueToString(json, false))) { VIR_TEST_VERBOSE("%s", "failed to stringize result\n"); - goto cleanup; + return -1; } - if (virTestCompareToFile(actual, outfile) < 0) - goto cleanup; =20 - ret =3D 0; + if (virTestCompareToFile(actual, outfile) < 0) + return -1; =20 - cleanup: - return ret; + return 0; } =20 =20 @@ -147,13 +138,11 @@ testJSONLookup(const void *data) int rc; int number; const char *str; - int ret =3D -1; =20 json =3D virJSONValueFromString(info->doc); if (!json) { VIR_TEST_VERBOSE("Fail to parse %s\n", info->doc); - ret =3D -1; - goto cleanup; + return -1; } =20 value =3D virJSONValueObjectGetObject(json, "a"); @@ -161,21 +150,21 @@ testJSONLookup(const void *data) if (!info->pass) { VIR_TEST_VERBOSE("lookup for 'a' in '%s' should have failed\n", info->doc); - goto cleanup; + return -1; } else { result =3D virJSONValueToString(value, false); if (STRNEQ_NULLABLE(result, "{}")) { VIR_TEST_VERBOSE("lookup for 'a' in '%s' found '%s' but " "should have found '{}'\n", info->doc, NULLSTR(result)); - goto cleanup; + return -1; } VIR_FREE(result); } } else if (info->pass) { VIR_TEST_VERBOSE("lookup for 'a' in '%s' should have succeeded\n", info->doc); - goto cleanup; + return -1; } =20 number =3D 2; @@ -184,17 +173,17 @@ testJSONLookup(const void *data) if (!info->pass) { VIR_TEST_VERBOSE("lookup for 'b' in '%s' should have failed\n", info->doc); - goto cleanup; + return -1; } else if (number !=3D 1) { VIR_TEST_VERBOSE("lookup for 'b' in '%s' found %d but " "should have found 1\n", info->doc, number); - goto cleanup; + return -1; } } else if (info->pass) { VIR_TEST_VERBOSE("lookup for 'b' in '%s' should have succeeded\n", info->doc); - goto cleanup; + return -1; } =20 str =3D virJSONValueObjectGetString(json, "c"); @@ -202,16 +191,16 @@ testJSONLookup(const void *data) if (!info->pass) { VIR_TEST_VERBOSE("lookup for 'c' in '%s' should have failed\n", info->doc); - goto cleanup; + return -1; } else if (STRNEQ(str, "str")) { VIR_TEST_VERBOSE("lookup for 'c' in '%s' found '%s' but " "should have found 'str'\n", info->doc, str); - goto cleanup; + return -1; } } else if (info->pass) { VIR_TEST_VERBOSE("lookup for 'c' in '%s' should have succeeded\n", info->doc); - goto cleanup; + return -1; } =20 value =3D virJSONValueObjectGetArray(json, "d"); @@ -219,27 +208,24 @@ testJSONLookup(const void *data) if (!info->pass) { VIR_TEST_VERBOSE("lookup for 'd' in '%s' should have failed\n", info->doc); - goto cleanup; + return -1; } else { result =3D virJSONValueToString(value, false); if (STRNEQ_NULLABLE(result, "[]")) { VIR_TEST_VERBOSE("lookup for 'd' in '%s' found '%s' but " "should have found '[]'\n", info->doc, NULLSTR(result)); - goto cleanup; + return -1; } VIR_FREE(result); } } else if (info->pass) { VIR_TEST_VERBOSE("lookup for 'd' in '%s' should have succeeded\n", info->doc); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -251,36 +237,35 @@ testJSONCopy(const void *data) VIR_AUTOPTR(virJSONValue) jsonCopy =3D NULL; VIR_AUTOFREE(char *) result =3D NULL; VIR_AUTOFREE(char *) resultCopy =3D NULL; - int ret =3D -1; =20 json =3D virJSONValueFromString(info->doc); if (!json) { VIR_TEST_VERBOSE("Failed to parse %s\n", info->doc); - goto cleanup; + return -1; } =20 jsonCopy =3D virJSONValueCopy(json); if (!jsonCopy) { VIR_TEST_VERBOSE("Failed to copy JSON data\n"); - goto cleanup; + return -1; } =20 result =3D virJSONValueToString(json, false); if (!result) { VIR_TEST_VERBOSE("Failed to format original JSON data\n"); - goto cleanup; + return -1; } =20 resultCopy =3D virJSONValueToString(json, false); if (!resultCopy) { VIR_TEST_VERBOSE("Failed to format copied JSON data\n"); - goto cleanup; + return -1; } =20 if (STRNEQ(result, resultCopy)) { if (virTestGetVerbose()) virTestDifference(stderr, result, resultCopy); - goto cleanup; + return -1; } =20 VIR_FREE(result); @@ -289,24 +274,22 @@ testJSONCopy(const void *data) result =3D virJSONValueToString(json, true); if (!result) { VIR_TEST_VERBOSE("Failed to format original JSON data\n"); - goto cleanup; + return -1; } =20 resultCopy =3D virJSONValueToString(json, true); if (!resultCopy) { VIR_TEST_VERBOSE("Failed to format copied JSON data\n"); - goto cleanup; + return -1; } =20 if (STRNEQ(result, resultCopy)) { if (virTestGetVerbose()) virTestDifference(stderr, result, resultCopy); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -320,43 +303,38 @@ testJSONDeflatten(const void *data) VIR_AUTOFREE(char *) indata =3D NULL; VIR_AUTOFREE(char *) outfile =3D NULL; VIR_AUTOFREE(char *) actual =3D NULL; - int ret =3D -1; =20 if (virAsprintf(&infile, "%s/virjsondata/deflatten-%s-in.json", abs_srcdir, info->name) < 0 || virAsprintf(&outfile, "%s/virjsondata/deflatten-%s-out.json", abs_srcdir, info->name) < 0) - goto cleanup; + return -1; =20 if (virTestLoadFile(infile, &indata) < 0) - goto cleanup; + return -1; =20 if (!(injson =3D virJSONValueFromString(indata))) - goto cleanup; + return -1; =20 if ((deflattened =3D virJSONValueObjectDeflatten(injson))) { if (!info->pass) { VIR_TEST_VERBOSE("%s: deflattening should have failed\n", info= ->name); - goto cleanup; + return -1; } } else { if (!info->pass) - ret =3D 0; + return 0; =20 - goto cleanup; + return -1; } =20 if (!(actual =3D virJSONValueToString(deflattened, true))) - goto cleanup; + return -1; =20 if (virTestCompareToFile(actual, outfile) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - - return ret; + return 0; } =20 =20 @@ -369,50 +347,46 @@ testJSONEscapeObj(const void *data ATTRIBUTE_UNUSED) VIR_AUTOFREE(char *) neststr =3D NULL; VIR_AUTOFREE(char *) result =3D NULL; const char *parsednestedstr; - int ret =3D -1; =20 if (virJSONValueObjectCreate(&nestjson, "s:stringkey", "stringvalue", "i:numberkey", 1234, "b:booleankey", false, NULL) < 0) { VIR_TEST_VERBOSE("failed to create nested json object"); - goto cleanup; + return -1; } =20 if (!(neststr =3D virJSONValueToString(nestjson, false))) { VIR_TEST_VERBOSE("failed to format nested json object"); - goto cleanup; + return -1; } =20 if (virJSONValueObjectCreate(&json, "s:test", neststr, NULL) < 0) { VIR_TEST_VERBOSE("Failed to create json object"); - goto cleanup; + return -1; } =20 if (!(result =3D virJSONValueToString(json, false))) { VIR_TEST_VERBOSE("Failed to format json object"); - goto cleanup; + return -1; } =20 if (!(parsejson =3D virJSONValueFromString(result))) { VIR_TEST_VERBOSE("Failed to parse JSON with nested JSON in string"= ); - goto cleanup; + return -1; } =20 if (!(parsednestedstr =3D virJSONValueObjectGetString(parsejson, "test= "))) { VIR_TEST_VERBOSE("Failed to retrieve string containing nested json= "); - goto cleanup; + return -1; } =20 if (STRNEQ(parsednestedstr, neststr)) { virTestDifference(stderr, neststr, parsednestedstr); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -423,7 +397,6 @@ testJSONObjectFormatSteal(const void *opaque ATTRIBUTE_= UNUSED) VIR_AUTOPTR(virJSONValue) a2 =3D NULL; VIR_AUTOPTR(virJSONValue) t1 =3D NULL; VIR_AUTOPTR(virJSONValue) t2 =3D NULL; - int ret =3D -1; =20 if (!(a1 =3D virJSONValueNewString("test")) || !(a2 =3D virJSONValueNewString("test"))) { @@ -432,28 +405,25 @@ testJSONObjectFormatSteal(const void *opaque ATTRIBUT= E_UNUSED) =20 if (virJSONValueObjectCreate(&t1, "a:t", &a1, "s:f", NULL, NULL) !=3D = -1) { VIR_TEST_VERBOSE("virJSONValueObjectCreate(t1) should have failed\= n"); - goto cleanup; + return -1; } =20 if (a1) { VIR_TEST_VERBOSE("appended object a1 was not consumed\n"); - goto cleanup; + return -1; } =20 if (virJSONValueObjectCreate(&t2, "s:f", NULL, "a:t", &a1, NULL) !=3D = -1) { VIR_TEST_VERBOSE("virJSONValueObjectCreate(t2) should have failed\= n"); - goto cleanup; + return -1; } =20 if (!a2) { VIR_TEST_VERBOSE("appended object a2 was consumed\n"); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 06:41:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554219809916182.87141252653032; Tue, 2 Apr 2019 08:43:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5C71F88302; Tue, 2 Apr 2019 15:43:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3768D18E22; Tue, 2 Apr 2019 15:43:28 +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 DD92818033A2; Tue, 2 Apr 2019 15:43:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x32FgCrK011887 for ; Tue, 2 Apr 2019 11:42:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id CEF185C21A; Tue, 2 Apr 2019 15:42:12 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56A345C6B3 for ; Tue, 2 Apr 2019 15:42:12 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 2 Apr 2019 17:41:46 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCHv2 07/14] virjsontest: introduce DO_TEST_PARSE_FILE 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 02 Apr 2019 15:43:28 +0000 (UTC) Introduce a new macro DO_TEST_PARSE_FILE which takes the input JSON from a file instead of a C string. This lets us get rid of quote escaping and makes the JSON easier to edit. The output JSON is still taken from a string and will be moved separately. Signed-off-by: J=C3=A1n Tomko --- tests/virjsondata/parse-Harder-in.json | 4 + tests/virjsondata/parse-NotSoSimple-in.json | 3 + tests/virjsondata/parse-Simple-in.json | 1 + tests/virjsondata/parse-VeryHard-in.json | 24 ++++ tests/virjsontest.c | 129 +++++++++++++------- 5 files changed, 118 insertions(+), 43 deletions(-) create mode 100644 tests/virjsondata/parse-Harder-in.json create mode 100644 tests/virjsondata/parse-NotSoSimple-in.json create mode 100644 tests/virjsondata/parse-Simple-in.json create mode 100644 tests/virjsondata/parse-VeryHard-in.json diff --git a/tests/virjsondata/parse-Harder-in.json b/tests/virjsondata/par= se-Harder-in.json new file mode 100644 index 0000000000..739d780fb9 --- /dev/null +++ b/tests/virjsondata/parse-Harder-in.json @@ -0,0 +1,4 @@ +{"return": [{"filename": \ +"unix:/home/berrange/.libvirt/qemu/lib/tck.monitor,server",\ +"label": "charmonitor"}, {"filename": "pty:/dev/pts/158",\ +"label": "charserial0"}], "id": "libvirt-3"} diff --git a/tests/virjsondata/parse-NotSoSimple-in.json b/tests/virjsondat= a/parse-NotSoSimple-in.json new file mode 100644 index 0000000000..bda5fd1c3f --- /dev/null +++ b/tests/virjsondata/parse-NotSoSimple-in.json @@ -0,0 +1,3 @@ +{"QMP": {"version": {"qemu":\ +{"micro": 91, "minor": 13, "major": 0},\ +"package": " (qemu-kvm-devel)"}, "capabilities": []}} diff --git a/tests/virjsondata/parse-Simple-in.json b/tests/virjsondata/par= se-Simple-in.json new file mode 100644 index 0000000000..a40724b322 --- /dev/null +++ b/tests/virjsondata/parse-Simple-in.json @@ -0,0 +1 @@ +{"return": {}, "id": "libvirt-1"} diff --git a/tests/virjsondata/parse-VeryHard-in.json b/tests/virjsondata/p= arse-VeryHard-in.json new file mode 100644 index 0000000000..e10d605950 --- /dev/null +++ b/tests/virjsondata/parse-VeryHard-in.json @@ -0,0 +1,24 @@ +{"return":[{"name":"quit"},{"name":\ +"eject"},{"name":"change"},{"name":"screendump"},\ +{"name":"stop"},{"name":"cont"},{"name":\ +"system_reset"},{"name":"system_powerdown"},\ +{"name":"device_add"},{"name":"device_del"},\ +{"name":"cpu"},{"name":"memsave"},{"name":\ +"pmemsave"},{"name":"migrate"},{"name":\ +"migrate_cancel"},{"name":"migrate_set_speed"},\ +{"name":"client_migrate_info"},{"name":\ +"migrate_set_downtime"},{"name":"netdev_add"},\ +{"name":"netdev_del"},{"name":"block_resize"},\ +{"name":"balloon"},{"name":"set_link"},{"name":\ +"getfd"},{"name":"closefd"},{"name":"block_passwd"},\ +{"name":"set_password"},{"name":"expire_password"},\ +{"name":"qmp_capabilities"},{"name":\ +"human-monitor-command"},{"name":"query-version"},\ +{"name":"query-commands"},{"name":"query-chardev"},\ +{"name":"query-block"},{"name":"query-blockstats"},\ +{"name":"query-cpus"},{"name":"query-pci"},{"name":\ +"query-kvm"},{"name":"query-status"},{"name":\ +"query-mice"},{"name":"query-vnc"},{"name":\ +"query-spice"},{"name":"query-name"},{"name":\ +"query-uuid"},{"name":"query-migrate"},{"name":\ +"query-balloon"}],"id":"libvirt-2"} diff --git a/tests/virjsontest.c b/tests/virjsontest.c index 0825a87188..262fcebca6 100644 --- a/tests/virjsontest.c +++ b/tests/virjsontest.c @@ -16,6 +16,51 @@ struct testInfo { }; =20 =20 +static int +testJSONFromFile(const void *data) +{ + const struct testInfo *info =3D data; + VIR_AUTOPTR(virJSONValue) injson =3D NULL; + VIR_AUTOFREE(char *) infile =3D NULL; + VIR_AUTOFREE(char *) indata =3D NULL; + VIR_AUTOFREE(char *) actual =3D NULL; + + if (virAsprintf(&infile, "%s/virjsondata/parse-%s-in.json", + abs_srcdir, info->name) < 0) + return -1; + + if (virTestLoadFile(infile, &indata) < 0) + return -1; + + injson =3D virJSONValueFromString(indata); + + if (!injson) { + if (info->pass) { + VIR_TEST_VERBOSE("Failed to parse %s\n", info->doc); + return -1; + } else { + VIR_TEST_DEBUG("As expected, failed to parse %s\n", info->doc); + return 0; + } + } else { + if (!info->pass) { + VIR_TEST_VERBOSE("Unexpected success while parsing %s\n", info= ->doc); + return -1; + } + } + + if (!(actual =3D virJSONValueToString(injson, false))) + return -1; + + if (STRNEQ(info->expect, actual)) { + virTestDifference(stderr, info->expect, actual); + return -1; + } + + return 0; +} + + static int testJSONFromString(const void *data) { @@ -454,49 +499,47 @@ mymain(void) #define DO_TEST_PARSE_FAIL(name, doc) \ DO_TEST_FULL(name, FromString, doc, NULL, false) =20 - - DO_TEST_PARSE("Simple", "{\"return\": {}, \"id\": \"libvirt-1\"}", - "{\"return\":{},\"id\":\"libvirt-1\"}"); - DO_TEST_PARSE("NotSoSimple", "{\"QMP\": {\"version\": {\"qemu\":" - "{\"micro\": 91, \"minor\": 13, \"major\": 0}," - "\"package\": \" (qemu-kvm-devel)\"}, \"capabilities\": = []}}", - "{\"QMP\":{\"version\":{\"qemu\":" - "{\"micro\":91,\"minor\":13,\"major\":0}," - "\"package\":\" (qemu-kvm-devel)\"},\"capabilities\":[]}= }"); - - DO_TEST_PARSE("Harder", "{\"return\": [{\"filename\": " - "\"unix:/home/berrange/.libvirt/qemu/lib/tck.monitor,ser= ver\"," - "\"label\": \"charmonitor\"}, {\"filename\": \"pty:/dev/= pts/158\"," - "\"label\": \"charserial0\"}], \"id\": \"libvirt-3\"}", - "{\"return\":[{\"filename\":" - "\"unix:/home/berrange/.libvirt/qemu/lib/tck.monitor,ser= ver\"," - "\"label\":\"charmonitor\"},{\"filename\":\"pty:/dev/pts= /158\"," - "\"label\":\"charserial0\"}],\"id\":\"libvirt-3\"}"); - - DO_TEST_PARSE("VeryHard", "{\"return\":[{\"name\":\"quit\"},{\"name\":" - "\"eject\"},{\"name\":\"change\"},{\"name\":\"screendump= \"}," - "{\"name\":\"stop\"},{\"name\":\"cont\"},{\"name\":" - "\"system_reset\"},{\"name\":\"system_powerdown\"}," - "{\"name\":\"device_add\"},{\"name\":\"device_del\"}," - "{\"name\":\"cpu\"},{\"name\":\"memsave\"},{\"name\":" - "\"pmemsave\"},{\"name\":\"migrate\"},{\"name\":" - "\"migrate_cancel\"},{\"name\":\"migrate_set_speed\"}," - "{\"name\":\"client_migrate_info\"},{\"name\":" - "\"migrate_set_downtime\"},{\"name\":\"netdev_add\"}," - "{\"name\":\"netdev_del\"},{\"name\":\"block_resize\"}," - "{\"name\":\"balloon\"},{\"name\":\"set_link\"},{\"name\= ":" - "\"getfd\"},{\"name\":\"closefd\"},{\"name\":\"block_pas= swd\"}," - "{\"name\":\"set_password\"},{\"name\":\"expire_password= \"}," - "{\"name\":\"qmp_capabilities\"},{\"name\":" - "\"human-monitor-command\"},{\"name\":\"query-version\"}= ," - "{\"name\":\"query-commands\"},{\"name\":\"query-chardev= \"}," - "{\"name\":\"query-block\"},{\"name\":\"query-blockstats= \"}," - "{\"name\":\"query-cpus\"},{\"name\":\"query-pci\"},{\"n= ame\":" - "\"query-kvm\"},{\"name\":\"query-status\"},{\"name\":" - "\"query-mice\"},{\"name\":\"query-vnc\"},{\"name\":" - "\"query-spice\"},{\"name\":\"query-name\"},{\"name\":" - "\"query-uuid\"},{\"name\":\"query-migrate\"},{\"name\":" - "\"query-balloon\"}],\"id\":\"libvirt-2\"}", NULL); +#define DO_TEST_PARSE_FILE(name, expect) \ + DO_TEST_FULL(name, FromFile, NULL, expect, true) + + + DO_TEST_PARSE_FILE("Simple", + "{\"return\":{},\"id\":\"libvirt-1\"}"); + DO_TEST_PARSE_FILE("NotSoSimple", + "{\"QMP\":{\"version\":{\"qemu\":" + "{\"micro\":91,\"minor\":13,\"major\":0}," + "\"package\":\" (qemu-kvm-devel)\"},\"capabilities\= ":[]}}"); + + DO_TEST_PARSE_FILE("Harder", + "{\"return\":[{\"filename\":" + "\"unix:/home/berrange/.libvirt/qemu/lib/tck.monito= r,server\"," + "\"label\":\"charmonitor\"},{\"filename\":\"pty:/de= v/pts/158\"," + "\"label\":\"charserial0\"}],\"id\":\"libvirt-3\"}"= ); + + DO_TEST_PARSE_FILE("VeryHard", "{\"return\":[{\"name\":\"quit\"},{\"na= me\":" + "\"eject\"},{\"name\":\"change\"},{\"name\":\"scree= ndump\"}," + "{\"name\":\"stop\"},{\"name\":\"cont\"},{\"name\":" + "\"system_reset\"},{\"name\":\"system_powerdown\"}," + "{\"name\":\"device_add\"},{\"name\":\"device_del\"= }," + "{\"name\":\"cpu\"},{\"name\":\"memsave\"},{\"name\= ":" + "\"pmemsave\"},{\"name\":\"migrate\"},{\"name\":" + "\"migrate_cancel\"},{\"name\":\"migrate_set_speed\= "}," + "{\"name\":\"client_migrate_info\"},{\"name\":" + "\"migrate_set_downtime\"},{\"name\":\"netdev_add\"= }," + "{\"name\":\"netdev_del\"},{\"name\":\"block_resize= \"}," + "{\"name\":\"balloon\"},{\"name\":\"set_link\"},{\"= name\":" + "\"getfd\"},{\"name\":\"closefd\"},{\"name\":\"bloc= k_passwd\"}," + "{\"name\":\"set_password\"},{\"name\":\"expire_pas= sword\"}," + "{\"name\":\"qmp_capabilities\"},{\"name\":" + "\"human-monitor-command\"},{\"name\":\"query-versi= on\"}," + "{\"name\":\"query-commands\"},{\"name\":\"query-ch= ardev\"}," + "{\"name\":\"query-block\"},{\"name\":\"query-block= stats\"}," + "{\"name\":\"query-cpus\"},{\"name\":\"query-pci\"}= ,{\"name\":" + "\"query-kvm\"},{\"name\":\"query-status\"},{\"name= \":" + "\"query-mice\"},{\"name\":\"query-vnc\"},{\"name\"= :" + "\"query-spice\"},{\"name\":\"query-name\"},{\"name= \":" + "\"query-uuid\"},{\"name\":\"query-migrate\"},{\"na= me\":" + "\"query-balloon\"}],\"id\":\"libvirt-2\"}"); =20 DO_TEST_FULL("success", AddRemove, NULL, NULL, true); DO_TEST_FULL("failure", AddRemove, NULL, NULL, false); --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 06:41:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554219816475965.6176442415843; Tue, 2 Apr 2019 08:43:36 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C724A2D7E7; Tue, 2 Apr 2019 15:43:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9518A108F824; Tue, 2 Apr 2019 15:43:34 +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 513E7180338B; Tue, 2 Apr 2019 15:43:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x32FgD80011895 for ; Tue, 2 Apr 2019 11:42:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id A03565C237; Tue, 2 Apr 2019 15:42:13 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 290CC5C21A for ; Tue, 2 Apr 2019 15:42:12 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 2 Apr 2019 17:41:47 +0200 Message-Id: <641c0ae6c587112e3b1389e2bfe9683503d9499e.1554219669.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCHv2 08/14] virjsontest: switch DO_TEST_PARSE_FILE to use output files 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 02 Apr 2019 15:43:35 +0000 (UTC) Also switch the expected output of DO_TEST_PARSE_FILE to be in a file, now that we demonstrated the input files match the expected string representation. Signed-off-by: J=C3=A1n Tomko --- tests/virjsondata/parse-Harder-out.json | 4 ++ tests/virjsondata/parse-NotSoSimple-out.json | 3 ++ tests/virjsondata/parse-Simple-out.json | 1 + tests/virjsondata/parse-VeryHard-out.json | 24 +++++++++ tests/virjsontest.c | 56 +++++--------------- 5 files changed, 44 insertions(+), 44 deletions(-) create mode 100644 tests/virjsondata/parse-Harder-out.json create mode 100644 tests/virjsondata/parse-NotSoSimple-out.json create mode 100644 tests/virjsondata/parse-Simple-out.json create mode 100644 tests/virjsondata/parse-VeryHard-out.json diff --git a/tests/virjsondata/parse-Harder-out.json b/tests/virjsondata/pa= rse-Harder-out.json new file mode 100644 index 0000000000..31b3edd731 --- /dev/null +++ b/tests/virjsondata/parse-Harder-out.json @@ -0,0 +1,4 @@ +{"return":[{"filename":\ +"unix:/home/berrange/.libvirt/qemu/lib/tck.monitor,server",\ +"label":"charmonitor"},{"filename":"pty:/dev/pts/158",\ +"label":"charserial0"}],"id":"libvirt-3"} diff --git a/tests/virjsondata/parse-NotSoSimple-out.json b/tests/virjsonda= ta/parse-NotSoSimple-out.json new file mode 100644 index 0000000000..e679cd1813 --- /dev/null +++ b/tests/virjsondata/parse-NotSoSimple-out.json @@ -0,0 +1,3 @@ +{"QMP":{"version":{"qemu":\ +{"micro":91,"minor":13,"major":0},\ +"package":" (qemu-kvm-devel)"},"capabilities":[]}} diff --git a/tests/virjsondata/parse-Simple-out.json b/tests/virjsondata/pa= rse-Simple-out.json new file mode 100644 index 0000000000..c6e85e1ceb --- /dev/null +++ b/tests/virjsondata/parse-Simple-out.json @@ -0,0 +1 @@ +{"return":{},"id":"libvirt-1"} diff --git a/tests/virjsondata/parse-VeryHard-out.json b/tests/virjsondata/= parse-VeryHard-out.json new file mode 100644 index 0000000000..e10d605950 --- /dev/null +++ b/tests/virjsondata/parse-VeryHard-out.json @@ -0,0 +1,24 @@ +{"return":[{"name":"quit"},{"name":\ +"eject"},{"name":"change"},{"name":"screendump"},\ +{"name":"stop"},{"name":"cont"},{"name":\ +"system_reset"},{"name":"system_powerdown"},\ +{"name":"device_add"},{"name":"device_del"},\ +{"name":"cpu"},{"name":"memsave"},{"name":\ +"pmemsave"},{"name":"migrate"},{"name":\ +"migrate_cancel"},{"name":"migrate_set_speed"},\ +{"name":"client_migrate_info"},{"name":\ +"migrate_set_downtime"},{"name":"netdev_add"},\ +{"name":"netdev_del"},{"name":"block_resize"},\ +{"name":"balloon"},{"name":"set_link"},{"name":\ +"getfd"},{"name":"closefd"},{"name":"block_passwd"},\ +{"name":"set_password"},{"name":"expire_password"},\ +{"name":"qmp_capabilities"},{"name":\ +"human-monitor-command"},{"name":"query-version"},\ +{"name":"query-commands"},{"name":"query-chardev"},\ +{"name":"query-block"},{"name":"query-blockstats"},\ +{"name":"query-cpus"},{"name":"query-pci"},{"name":\ +"query-kvm"},{"name":"query-status"},{"name":\ +"query-mice"},{"name":"query-vnc"},{"name":\ +"query-spice"},{"name":"query-name"},{"name":\ +"query-uuid"},{"name":"query-migrate"},{"name":\ +"query-balloon"}],"id":"libvirt-2"} diff --git a/tests/virjsontest.c b/tests/virjsontest.c index 262fcebca6..4241acd911 100644 --- a/tests/virjsontest.c +++ b/tests/virjsontest.c @@ -23,9 +23,12 @@ testJSONFromFile(const void *data) VIR_AUTOPTR(virJSONValue) injson =3D NULL; VIR_AUTOFREE(char *) infile =3D NULL; VIR_AUTOFREE(char *) indata =3D NULL; + VIR_AUTOFREE(char *) outfile =3D NULL; VIR_AUTOFREE(char *) actual =3D NULL; =20 if (virAsprintf(&infile, "%s/virjsondata/parse-%s-in.json", + abs_srcdir, info->name) < 0 || + virAsprintf(&outfile, "%s/virjsondata/parse-%s-out.json", abs_srcdir, info->name) < 0) return -1; =20 @@ -52,10 +55,8 @@ testJSONFromFile(const void *data) if (!(actual =3D virJSONValueToString(injson, false))) return -1; =20 - if (STRNEQ(info->expect, actual)) { - virTestDifference(stderr, info->expect, actual); + if (virTestCompareToFile(actual, outfile) < 0) return -1; - } =20 return 0; } @@ -499,47 +500,14 @@ mymain(void) #define DO_TEST_PARSE_FAIL(name, doc) \ DO_TEST_FULL(name, FromString, doc, NULL, false) =20 -#define DO_TEST_PARSE_FILE(name, expect) \ - DO_TEST_FULL(name, FromFile, NULL, expect, true) - - - DO_TEST_PARSE_FILE("Simple", - "{\"return\":{},\"id\":\"libvirt-1\"}"); - DO_TEST_PARSE_FILE("NotSoSimple", - "{\"QMP\":{\"version\":{\"qemu\":" - "{\"micro\":91,\"minor\":13,\"major\":0}," - "\"package\":\" (qemu-kvm-devel)\"},\"capabilities\= ":[]}}"); - - DO_TEST_PARSE_FILE("Harder", - "{\"return\":[{\"filename\":" - "\"unix:/home/berrange/.libvirt/qemu/lib/tck.monito= r,server\"," - "\"label\":\"charmonitor\"},{\"filename\":\"pty:/de= v/pts/158\"," - "\"label\":\"charserial0\"}],\"id\":\"libvirt-3\"}"= ); - - DO_TEST_PARSE_FILE("VeryHard", "{\"return\":[{\"name\":\"quit\"},{\"na= me\":" - "\"eject\"},{\"name\":\"change\"},{\"name\":\"scree= ndump\"}," - "{\"name\":\"stop\"},{\"name\":\"cont\"},{\"name\":" - "\"system_reset\"},{\"name\":\"system_powerdown\"}," - "{\"name\":\"device_add\"},{\"name\":\"device_del\"= }," - "{\"name\":\"cpu\"},{\"name\":\"memsave\"},{\"name\= ":" - "\"pmemsave\"},{\"name\":\"migrate\"},{\"name\":" - "\"migrate_cancel\"},{\"name\":\"migrate_set_speed\= "}," - "{\"name\":\"client_migrate_info\"},{\"name\":" - "\"migrate_set_downtime\"},{\"name\":\"netdev_add\"= }," - "{\"name\":\"netdev_del\"},{\"name\":\"block_resize= \"}," - "{\"name\":\"balloon\"},{\"name\":\"set_link\"},{\"= name\":" - "\"getfd\"},{\"name\":\"closefd\"},{\"name\":\"bloc= k_passwd\"}," - "{\"name\":\"set_password\"},{\"name\":\"expire_pas= sword\"}," - "{\"name\":\"qmp_capabilities\"},{\"name\":" - "\"human-monitor-command\"},{\"name\":\"query-versi= on\"}," - "{\"name\":\"query-commands\"},{\"name\":\"query-ch= ardev\"}," - "{\"name\":\"query-block\"},{\"name\":\"query-block= stats\"}," - "{\"name\":\"query-cpus\"},{\"name\":\"query-pci\"}= ,{\"name\":" - "\"query-kvm\"},{\"name\":\"query-status\"},{\"name= \":" - "\"query-mice\"},{\"name\":\"query-vnc\"},{\"name\"= :" - "\"query-spice\"},{\"name\":\"query-name\"},{\"name= \":" - "\"query-uuid\"},{\"name\":\"query-migrate\"},{\"na= me\":" - "\"query-balloon\"}],\"id\":\"libvirt-2\"}"); +#define DO_TEST_PARSE_FILE(name) \ + DO_TEST_FULL(name, FromFile, NULL, NULL, true) + + + DO_TEST_PARSE_FILE("Simple"); + DO_TEST_PARSE_FILE("NotSoSimple"); + DO_TEST_PARSE_FILE("Harder"); + DO_TEST_PARSE_FILE("VeryHard"); =20 DO_TEST_FULL("success", AddRemove, NULL, NULL, true); DO_TEST_FULL("failure", AddRemove, NULL, NULL, false); --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 06:41:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554219814819252.12258800968152; Tue, 2 Apr 2019 08:43:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 58977C05090C; Tue, 2 Apr 2019 15:43:33 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2D8F77FFFC; Tue, 2 Apr 2019 15:43:33 +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 D5F9B181A009; Tue, 2 Apr 2019 15:43:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x32FgIqb012213 for ; Tue, 2 Apr 2019 11:42:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 845355C21A; Tue, 2 Apr 2019 15:42:18 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0AEDC173F4 for ; Tue, 2 Apr 2019 15:42:13 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 2 Apr 2019 17:41:48 +0200 Message-Id: <1d0244f9c534a0b42808a52937065cb56d7a1145.1554219669.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCHv2 09/14] virjsontest: reformat add-remove test input data 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 02 Apr 2019 15:43:34 +0000 (UTC) Use json_reformat to make the input more readable. Signed-off-by: J=C3=A1n Tomko --- tests/virjsondata/add-remove-failure-in.json | 4 +++- tests/virjsondata/add-remove-success-in.json | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/virjsondata/add-remove-failure-in.json b/tests/virjsonda= ta/add-remove-failure-in.json index dd264421e9..7622214cf2 100644 --- a/tests/virjsondata/add-remove-failure-in.json +++ b/tests/virjsondata/add-remove-failure-in.json @@ -1 +1,3 @@ -[ 1 ] +[ + 1 +] diff --git a/tests/virjsondata/add-remove-success-in.json b/tests/virjsonda= ta/add-remove-success-in.json index b8edd30963..bdc86185c6 100644 --- a/tests/virjsondata/add-remove-success-in.json +++ b/tests/virjsondata/add-remove-success-in.json @@ -1 +1,4 @@ -{"name": "sample", "value": true} +{ + "name": "sample", + "value": true +} --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 06:41:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 155421981828065.56033334289089; Tue, 2 Apr 2019 08:43:38 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 34B0E80462; Tue, 2 Apr 2019 15:43:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0A3DB104C3D5; Tue, 2 Apr 2019 15:43:37 +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 B53E3181A12B; Tue, 2 Apr 2019 15:43:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x32FgJsW012226 for ; Tue, 2 Apr 2019 11:42:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5812A5C237; Tue, 2 Apr 2019 15:42:19 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D12FA5C6B3 for ; Tue, 2 Apr 2019 15:42:18 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 2 Apr 2019 17:41:49 +0200 Message-Id: <266dd049b835616a40d53492e00c07136d28ff94.1554219669.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCHv2 10/14] vvv--- squash into: json_reformat add-remove output data 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 02 Apr 2019 15:43:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" --- tests/virjsondata/add-remove-success-out.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/virjsondata/add-remove-success-out.json b/tests/virjsond= ata/add-remove-success-out.json index 9f1e44637c..50f1770910 100644 --- a/tests/virjsondata/add-remove-success-out.json +++ b/tests/virjsondata/add-remove-success-out.json @@ -1 +1,4 @@ -{"value":true,"newname":"foo"} +{ + "value": true, + "newname": "foo" +} --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 06:41:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554219819740137.51851805938384; Tue, 2 Apr 2019 08:43:39 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 80EF8C1306E5; Tue, 2 Apr 2019 15:43:38 +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 55600608B9; Tue, 2 Apr 2019 15:43:38 +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 1B5834ED2A; Tue, 2 Apr 2019 15:43:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x32FgKPO012231 for ; Tue, 2 Apr 2019 11:42:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 27DC05C237; Tue, 2 Apr 2019 15:42:20 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A3AF35C21A for ; Tue, 2 Apr 2019 15:42:19 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 2 Apr 2019 17:41:50 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCHv2 11/14] virjsontest: prettify AddRemove test 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 02 Apr 2019 15:43:39 +0000 (UTC) Signed-off-by: J=C3=A1n Tomko --- tests/virjsondata/add-remove-success-out.json | 4 ++-- tests/virjsontest.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/virjsondata/add-remove-success-out.json b/tests/virjsond= ata/add-remove-success-out.json index 50f1770910..24ccb3e38c 100644 --- a/tests/virjsondata/add-remove-success-out.json +++ b/tests/virjsondata/add-remove-success-out.json @@ -1,4 +1,4 @@ { - "value": true, - "newname": "foo" + "value": true, + "newname": "foo" } diff --git a/tests/virjsontest.c b/tests/virjsontest.c index 4241acd911..4a33aff785 100644 --- a/tests/virjsontest.c +++ b/tests/virjsontest.c @@ -162,7 +162,7 @@ testJSONAddRemove(const void *data) VIR_TEST_VERBOSE("%s", "unexpected failure adding new key\n"); return -1; } - if (!(actual =3D virJSONValueToString(json, false))) { + if (!(actual =3D virJSONValueToString(json, true))) { VIR_TEST_VERBOSE("%s", "failed to stringize result\n"); return -1; } --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 06:41:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554219823489366.60499138692796; Tue, 2 Apr 2019 08:43:43 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 458E181E05; Tue, 2 Apr 2019 15:43:42 +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 13797608B9; Tue, 2 Apr 2019 15:43:42 +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 A96DA4ED3F; Tue, 2 Apr 2019 15:43:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x32FgM8p012246 for ; Tue, 2 Apr 2019 11:42:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id B2B875C21A; Tue, 2 Apr 2019 15:42:22 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C0115C708 for ; Tue, 2 Apr 2019 15:42:20 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 2 Apr 2019 17:41:51 +0200 Message-Id: <60fee9c66744bc9aac0b0cdcb68def1b18f9ac64.1554219669.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCHv2 12/14] virjsondata: json_reformat input data 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 02 Apr 2019 15:43:42 +0000 (UTC) Remove trailing slashes and run json_reformat. Signed-off-by: J=C3=A1n Tomko --- tests/virjsondata/parse-Harder-in.json | 17 +- tests/virjsondata/parse-NotSoSimple-in.json | 18 ++- tests/virjsondata/parse-Simple-in.json | 7 +- tests/virjsondata/parse-VeryHard-in.json | 167 +++++++++++++++++--- 4 files changed, 177 insertions(+), 32 deletions(-) diff --git a/tests/virjsondata/parse-Harder-in.json b/tests/virjsondata/par= se-Harder-in.json index 739d780fb9..1cdac1f0c9 100644 --- a/tests/virjsondata/parse-Harder-in.json +++ b/tests/virjsondata/parse-Harder-in.json @@ -1,4 +1,13 @@ -{"return": [{"filename": \ -"unix:/home/berrange/.libvirt/qemu/lib/tck.monitor,server",\ -"label": "charmonitor"}, {"filename": "pty:/dev/pts/158",\ -"label": "charserial0"}], "id": "libvirt-3"} +{ + "return": [ + { + "filename": "unix:/home/berrange/.libvirt/qemu/lib/tck.monitor= ,server", + "label": "charmonitor" + }, + { + "filename": "pty:/dev/pts/158", + "label": "charserial0" + } + ], + "id": "libvirt-3" +} diff --git a/tests/virjsondata/parse-NotSoSimple-in.json b/tests/virjsondat= a/parse-NotSoSimple-in.json index bda5fd1c3f..c6553b74af 100644 --- a/tests/virjsondata/parse-NotSoSimple-in.json +++ b/tests/virjsondata/parse-NotSoSimple-in.json @@ -1,3 +1,15 @@ -{"QMP": {"version": {"qemu":\ -{"micro": 91, "minor": 13, "major": 0},\ -"package": " (qemu-kvm-devel)"}, "capabilities": []}} +{ + "QMP": { + "version": { + "qemu": { + "micro": 91, + "minor": 13, + "major": 0 + }, + "package": " (qemu-kvm-devel)" + }, + "capabilities": [ + + ] + } +} diff --git a/tests/virjsondata/parse-Simple-in.json b/tests/virjsondata/par= se-Simple-in.json index a40724b322..167bdccdf8 100644 --- a/tests/virjsondata/parse-Simple-in.json +++ b/tests/virjsondata/parse-Simple-in.json @@ -1 +1,6 @@ -{"return": {}, "id": "libvirt-1"} +{ + "return": { + + }, + "id": "libvirt-1" +} diff --git a/tests/virjsondata/parse-VeryHard-in.json b/tests/virjsondata/p= arse-VeryHard-in.json index e10d605950..dc64fc1661 100644 --- a/tests/virjsondata/parse-VeryHard-in.json +++ b/tests/virjsondata/parse-VeryHard-in.json @@ -1,24 +1,143 @@ -{"return":[{"name":"quit"},{"name":\ -"eject"},{"name":"change"},{"name":"screendump"},\ -{"name":"stop"},{"name":"cont"},{"name":\ -"system_reset"},{"name":"system_powerdown"},\ -{"name":"device_add"},{"name":"device_del"},\ -{"name":"cpu"},{"name":"memsave"},{"name":\ -"pmemsave"},{"name":"migrate"},{"name":\ -"migrate_cancel"},{"name":"migrate_set_speed"},\ -{"name":"client_migrate_info"},{"name":\ -"migrate_set_downtime"},{"name":"netdev_add"},\ -{"name":"netdev_del"},{"name":"block_resize"},\ -{"name":"balloon"},{"name":"set_link"},{"name":\ -"getfd"},{"name":"closefd"},{"name":"block_passwd"},\ -{"name":"set_password"},{"name":"expire_password"},\ -{"name":"qmp_capabilities"},{"name":\ -"human-monitor-command"},{"name":"query-version"},\ -{"name":"query-commands"},{"name":"query-chardev"},\ -{"name":"query-block"},{"name":"query-blockstats"},\ -{"name":"query-cpus"},{"name":"query-pci"},{"name":\ -"query-kvm"},{"name":"query-status"},{"name":\ -"query-mice"},{"name":"query-vnc"},{"name":\ -"query-spice"},{"name":"query-name"},{"name":\ -"query-uuid"},{"name":"query-migrate"},{"name":\ -"query-balloon"}],"id":"libvirt-2"} +{ + "return": [ + { + "name": "quit" + }, + { + "name": "eject" + }, + { + "name": "change" + }, + { + "name": "screendump" + }, + { + "name": "stop" + }, + { + "name": "cont" + }, + { + "name": "system_reset" + }, + { + "name": "system_powerdown" + }, + { + "name": "device_add" + }, + { + "name": "device_del" + }, + { + "name": "cpu" + }, + { + "name": "memsave" + }, + { + "name": "pmemsave" + }, + { + "name": "migrate" + }, + { + "name": "migrate_cancel" + }, + { + "name": "migrate_set_speed" + }, + { + "name": "client_migrate_info" + }, + { + "name": "migrate_set_downtime" + }, + { + "name": "netdev_add" + }, + { + "name": "netdev_del" + }, + { + "name": "block_resize" + }, + { + "name": "balloon" + }, + { + "name": "set_link" + }, + { + "name": "getfd" + }, + { + "name": "closefd" + }, + { + "name": "block_passwd" + }, + { + "name": "set_password" + }, + { + "name": "expire_password" + }, + { + "name": "qmp_capabilities" + }, + { + "name": "human-monitor-command" + }, + { + "name": "query-version" + }, + { + "name": "query-commands" + }, + { + "name": "query-chardev" + }, + { + "name": "query-block" + }, + { + "name": "query-blockstats" + }, + { + "name": "query-cpus" + }, + { + "name": "query-pci" + }, + { + "name": "query-kvm" + }, + { + "name": "query-status" + }, + { + "name": "query-mice" + }, + { + "name": "query-vnc" + }, + { + "name": "query-spice" + }, + { + "name": "query-name" + }, + { + "name": "query-uuid" + }, + { + "name": "query-migrate" + }, + { + "name": "query-balloon" + } + ], + "id": "libvirt-2" +} --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 06:41:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554219831285329.2193317822024; Tue, 2 Apr 2019 08:43:51 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3035A30715CA; Tue, 2 Apr 2019 15:43:50 +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 0639E6248C; Tue, 2 Apr 2019 15:43:50 +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 B1A0E4EE07; Tue, 2 Apr 2019 15:43:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x32FgNaR012256 for ; Tue, 2 Apr 2019 11:42:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 85AC75C21A; Tue, 2 Apr 2019 15:42:23 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C5015C237 for ; Tue, 2 Apr 2019 15:42:22 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 2 Apr 2019 17:41:52 +0200 Message-Id: <88a6144e77524965a22c9431953971da7e967871.1554219669.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCHv2 13/14] vvv SQUASH HERE: reformat parseFile output data 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 02 Apr 2019 15:43:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Remove trailing slashes and call json_reformat --- tests/virjsondata/parse-Harder-out.json | 17 +- tests/virjsondata/parse-NotSoSimple-out.json | 18 +- tests/virjsondata/parse-Simple-out.json | 7 +- tests/virjsondata/parse-VeryHard-out.json | 167 ++++++++++++++++--- 4 files changed, 177 insertions(+), 32 deletions(-) diff --git a/tests/virjsondata/parse-Harder-out.json b/tests/virjsondata/pa= rse-Harder-out.json index 31b3edd731..1cdac1f0c9 100644 --- a/tests/virjsondata/parse-Harder-out.json +++ b/tests/virjsondata/parse-Harder-out.json @@ -1,4 +1,13 @@ -{"return":[{"filename":\ -"unix:/home/berrange/.libvirt/qemu/lib/tck.monitor,server",\ -"label":"charmonitor"},{"filename":"pty:/dev/pts/158",\ -"label":"charserial0"}],"id":"libvirt-3"} +{ + "return": [ + { + "filename": "unix:/home/berrange/.libvirt/qemu/lib/tck.monitor= ,server", + "label": "charmonitor" + }, + { + "filename": "pty:/dev/pts/158", + "label": "charserial0" + } + ], + "id": "libvirt-3" +} diff --git a/tests/virjsondata/parse-NotSoSimple-out.json b/tests/virjsonda= ta/parse-NotSoSimple-out.json index e679cd1813..c6553b74af 100644 --- a/tests/virjsondata/parse-NotSoSimple-out.json +++ b/tests/virjsondata/parse-NotSoSimple-out.json @@ -1,3 +1,15 @@ -{"QMP":{"version":{"qemu":\ -{"micro":91,"minor":13,"major":0},\ -"package":" (qemu-kvm-devel)"},"capabilities":[]}} +{ + "QMP": { + "version": { + "qemu": { + "micro": 91, + "minor": 13, + "major": 0 + }, + "package": " (qemu-kvm-devel)" + }, + "capabilities": [ + + ] + } +} diff --git a/tests/virjsondata/parse-Simple-out.json b/tests/virjsondata/pa= rse-Simple-out.json index c6e85e1ceb..167bdccdf8 100644 --- a/tests/virjsondata/parse-Simple-out.json +++ b/tests/virjsondata/parse-Simple-out.json @@ -1 +1,6 @@ -{"return":{},"id":"libvirt-1"} +{ + "return": { + + }, + "id": "libvirt-1" +} diff --git a/tests/virjsondata/parse-VeryHard-out.json b/tests/virjsondata/= parse-VeryHard-out.json index e10d605950..dc64fc1661 100644 --- a/tests/virjsondata/parse-VeryHard-out.json +++ b/tests/virjsondata/parse-VeryHard-out.json @@ -1,24 +1,143 @@ -{"return":[{"name":"quit"},{"name":\ -"eject"},{"name":"change"},{"name":"screendump"},\ -{"name":"stop"},{"name":"cont"},{"name":\ -"system_reset"},{"name":"system_powerdown"},\ -{"name":"device_add"},{"name":"device_del"},\ -{"name":"cpu"},{"name":"memsave"},{"name":\ -"pmemsave"},{"name":"migrate"},{"name":\ -"migrate_cancel"},{"name":"migrate_set_speed"},\ -{"name":"client_migrate_info"},{"name":\ -"migrate_set_downtime"},{"name":"netdev_add"},\ -{"name":"netdev_del"},{"name":"block_resize"},\ -{"name":"balloon"},{"name":"set_link"},{"name":\ -"getfd"},{"name":"closefd"},{"name":"block_passwd"},\ -{"name":"set_password"},{"name":"expire_password"},\ -{"name":"qmp_capabilities"},{"name":\ -"human-monitor-command"},{"name":"query-version"},\ -{"name":"query-commands"},{"name":"query-chardev"},\ -{"name":"query-block"},{"name":"query-blockstats"},\ -{"name":"query-cpus"},{"name":"query-pci"},{"name":\ -"query-kvm"},{"name":"query-status"},{"name":\ -"query-mice"},{"name":"query-vnc"},{"name":\ -"query-spice"},{"name":"query-name"},{"name":\ -"query-uuid"},{"name":"query-migrate"},{"name":\ -"query-balloon"}],"id":"libvirt-2"} +{ + "return": [ + { + "name": "quit" + }, + { + "name": "eject" + }, + { + "name": "change" + }, + { + "name": "screendump" + }, + { + "name": "stop" + }, + { + "name": "cont" + }, + { + "name": "system_reset" + }, + { + "name": "system_powerdown" + }, + { + "name": "device_add" + }, + { + "name": "device_del" + }, + { + "name": "cpu" + }, + { + "name": "memsave" + }, + { + "name": "pmemsave" + }, + { + "name": "migrate" + }, + { + "name": "migrate_cancel" + }, + { + "name": "migrate_set_speed" + }, + { + "name": "client_migrate_info" + }, + { + "name": "migrate_set_downtime" + }, + { + "name": "netdev_add" + }, + { + "name": "netdev_del" + }, + { + "name": "block_resize" + }, + { + "name": "balloon" + }, + { + "name": "set_link" + }, + { + "name": "getfd" + }, + { + "name": "closefd" + }, + { + "name": "block_passwd" + }, + { + "name": "set_password" + }, + { + "name": "expire_password" + }, + { + "name": "qmp_capabilities" + }, + { + "name": "human-monitor-command" + }, + { + "name": "query-version" + }, + { + "name": "query-commands" + }, + { + "name": "query-chardev" + }, + { + "name": "query-block" + }, + { + "name": "query-blockstats" + }, + { + "name": "query-cpus" + }, + { + "name": "query-pci" + }, + { + "name": "query-kvm" + }, + { + "name": "query-status" + }, + { + "name": "query-mice" + }, + { + "name": "query-vnc" + }, + { + "name": "query-spice" + }, + { + "name": "query-name" + }, + { + "name": "query-uuid" + }, + { + "name": "query-migrate" + }, + { + "name": "query-balloon" + } + ], + "id": "libvirt-2" +} --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 06:41:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554219824298158.73883786225213; Tue, 2 Apr 2019 08:43:44 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AEC9731688FD; Tue, 2 Apr 2019 15:43:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 83D60108F81E; Tue, 2 Apr 2019 15:43:42 +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 411CE181A135; Tue, 2 Apr 2019 15:43:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x32FgOiN012261 for ; Tue, 2 Apr 2019 11:42:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 561BF5C57E; Tue, 2 Apr 2019 15:42:24 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D12A75C21A for ; Tue, 2 Apr 2019 15:42:23 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 2 Apr 2019 17:41:53 +0200 Message-Id: <220cc0479d4137b7cbda93a6d247fcafe43d66b7.1554219669.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCHv2 14/14] virjsontest: prettify JSONFromFile test 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Tue, 02 Apr 2019 15:43:43 +0000 (UTC) Signed-off-by: J=C3=A1n Tomko --- tests/virjsondata/parse-Harder-out.json | 22 +- tests/virjsondata/parse-NotSoSimple-out.json | 24 +- tests/virjsondata/parse-Simple-out.json | 6 +- tests/virjsondata/parse-VeryHard-out.json | 282 +++++++++---------- tests/virjsontest.c | 2 +- 5 files changed, 168 insertions(+), 168 deletions(-) diff --git a/tests/virjsondata/parse-Harder-out.json b/tests/virjsondata/pa= rse-Harder-out.json index 1cdac1f0c9..6088af7167 100644 --- a/tests/virjsondata/parse-Harder-out.json +++ b/tests/virjsondata/parse-Harder-out.json @@ -1,13 +1,13 @@ { - "return": [ - { - "filename": "unix:/home/berrange/.libvirt/qemu/lib/tck.monitor= ,server", - "label": "charmonitor" - }, - { - "filename": "pty:/dev/pts/158", - "label": "charserial0" - } - ], - "id": "libvirt-3" + "return": [ + { + "filename": "unix:/home/berrange/.libvirt/qemu/lib/tck.monitor,serve= r", + "label": "charmonitor" + }, + { + "filename": "pty:/dev/pts/158", + "label": "charserial0" + } + ], + "id": "libvirt-3" } diff --git a/tests/virjsondata/parse-NotSoSimple-out.json b/tests/virjsonda= ta/parse-NotSoSimple-out.json index c6553b74af..0eb07b0670 100644 --- a/tests/virjsondata/parse-NotSoSimple-out.json +++ b/tests/virjsondata/parse-NotSoSimple-out.json @@ -1,15 +1,15 @@ { - "QMP": { - "version": { - "qemu": { - "micro": 91, - "minor": 13, - "major": 0 - }, - "package": " (qemu-kvm-devel)" - }, - "capabilities": [ + "QMP": { + "version": { + "qemu": { + "micro": 91, + "minor": 13, + "major": 0 + }, + "package": " (qemu-kvm-devel)" + }, + "capabilities": [ =20 - ] - } + ] + } } diff --git a/tests/virjsondata/parse-Simple-out.json b/tests/virjsondata/pa= rse-Simple-out.json index 167bdccdf8..29dcfe01ef 100644 --- a/tests/virjsondata/parse-Simple-out.json +++ b/tests/virjsondata/parse-Simple-out.json @@ -1,6 +1,6 @@ { - "return": { + "return": { =20 - }, - "id": "libvirt-1" + }, + "id": "libvirt-1" } diff --git a/tests/virjsondata/parse-VeryHard-out.json b/tests/virjsondata/= parse-VeryHard-out.json index dc64fc1661..38e7b4df5e 100644 --- a/tests/virjsondata/parse-VeryHard-out.json +++ b/tests/virjsondata/parse-VeryHard-out.json @@ -1,143 +1,143 @@ { - "return": [ - { - "name": "quit" - }, - { - "name": "eject" - }, - { - "name": "change" - }, - { - "name": "screendump" - }, - { - "name": "stop" - }, - { - "name": "cont" - }, - { - "name": "system_reset" - }, - { - "name": "system_powerdown" - }, - { - "name": "device_add" - }, - { - "name": "device_del" - }, - { - "name": "cpu" - }, - { - "name": "memsave" - }, - { - "name": "pmemsave" - }, - { - "name": "migrate" - }, - { - "name": "migrate_cancel" - }, - { - "name": "migrate_set_speed" - }, - { - "name": "client_migrate_info" - }, - { - "name": "migrate_set_downtime" - }, - { - "name": "netdev_add" - }, - { - "name": "netdev_del" - }, - { - "name": "block_resize" - }, - { - "name": "balloon" - }, - { - "name": "set_link" - }, - { - "name": "getfd" - }, - { - "name": "closefd" - }, - { - "name": "block_passwd" - }, - { - "name": "set_password" - }, - { - "name": "expire_password" - }, - { - "name": "qmp_capabilities" - }, - { - "name": "human-monitor-command" - }, - { - "name": "query-version" - }, - { - "name": "query-commands" - }, - { - "name": "query-chardev" - }, - { - "name": "query-block" - }, - { - "name": "query-blockstats" - }, - { - "name": "query-cpus" - }, - { - "name": "query-pci" - }, - { - "name": "query-kvm" - }, - { - "name": "query-status" - }, - { - "name": "query-mice" - }, - { - "name": "query-vnc" - }, - { - "name": "query-spice" - }, - { - "name": "query-name" - }, - { - "name": "query-uuid" - }, - { - "name": "query-migrate" - }, - { - "name": "query-balloon" - } - ], - "id": "libvirt-2" + "return": [ + { + "name": "quit" + }, + { + "name": "eject" + }, + { + "name": "change" + }, + { + "name": "screendump" + }, + { + "name": "stop" + }, + { + "name": "cont" + }, + { + "name": "system_reset" + }, + { + "name": "system_powerdown" + }, + { + "name": "device_add" + }, + { + "name": "device_del" + }, + { + "name": "cpu" + }, + { + "name": "memsave" + }, + { + "name": "pmemsave" + }, + { + "name": "migrate" + }, + { + "name": "migrate_cancel" + }, + { + "name": "migrate_set_speed" + }, + { + "name": "client_migrate_info" + }, + { + "name": "migrate_set_downtime" + }, + { + "name": "netdev_add" + }, + { + "name": "netdev_del" + }, + { + "name": "block_resize" + }, + { + "name": "balloon" + }, + { + "name": "set_link" + }, + { + "name": "getfd" + }, + { + "name": "closefd" + }, + { + "name": "block_passwd" + }, + { + "name": "set_password" + }, + { + "name": "expire_password" + }, + { + "name": "qmp_capabilities" + }, + { + "name": "human-monitor-command" + }, + { + "name": "query-version" + }, + { + "name": "query-commands" + }, + { + "name": "query-chardev" + }, + { + "name": "query-block" + }, + { + "name": "query-blockstats" + }, + { + "name": "query-cpus" + }, + { + "name": "query-pci" + }, + { + "name": "query-kvm" + }, + { + "name": "query-status" + }, + { + "name": "query-mice" + }, + { + "name": "query-vnc" + }, + { + "name": "query-spice" + }, + { + "name": "query-name" + }, + { + "name": "query-uuid" + }, + { + "name": "query-migrate" + }, + { + "name": "query-balloon" + } + ], + "id": "libvirt-2" } diff --git a/tests/virjsontest.c b/tests/virjsontest.c index 4a33aff785..9dcdd90b2d 100644 --- a/tests/virjsontest.c +++ b/tests/virjsontest.c @@ -52,7 +52,7 @@ testJSONFromFile(const void *data) } } =20 - if (!(actual =3D virJSONValueToString(injson, false))) + if (!(actual =3D virJSONValueToString(injson, true))) return -1; =20 if (virTestCompareToFile(actual, outfile) < 0) --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list