From nobody Thu Jul 10 00:41:16 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1501063420525166.4428324220777; Wed, 26 Jul 2017 03:03:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 99A797EA8A; Wed, 26 Jul 2017 10:03: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 ED58577EE1; Wed, 26 Jul 2017 10:03:36 +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 361FA180BA97; Wed, 26 Jul 2017 10:03:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6QA13eF008815 for ; Wed, 26 Jul 2017 06:01:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4F48C6FE7B; Wed, 26 Jul 2017 10:01:03 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id A008B6FE76; Wed, 26 Jul 2017 10:01:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 99A797EA8A Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 26 Jul 2017 12:00:40 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 10/24] tests: qemumonitorjson: simplify path handling in testBlockNodeNameDetect 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: , MIME-Version: 1.0 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 26 Jul 2017 10:03:38 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Extract the test prefix path into a variable and reuse virTestLoadFileJSON to load the sample json files rather than doing it manually. --- tests/qemumonitorjsontest.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 56a0a25e1..268c15f4b 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2736,8 +2736,7 @@ static int testBlockNodeNameDetect(const void *opaque) { const struct testBlockNodeNameDetectData *data =3D opaque; - char *namedNodesFile =3D NULL; - char *namedNodesStr =3D NULL; + const char *pathprefix =3D "qemumonitorjsondata/qemumonitorjson-nodena= me-"; char *resultFile =3D NULL; char *actual =3D NULL; char **nodenames =3D NULL; @@ -2747,21 +2746,15 @@ testBlockNodeNameDetect(const void *opaque) virBuffer buf =3D VIR_BUFFER_INITIALIZER; int ret =3D -1; - if (virAsprintf(&namedNodesFile, - "%s/qemumonitorjsondata/qemumonitorjson-nodename-%s-na= med-nodes.json", - abs_srcdir, data->name) < 0 || - virAsprintf(&resultFile, - "%s/qemumonitorjsondata/qemumonitorjson-nodename-%s.re= sult", - abs_srcdir, data->name) < 0) + if (virAsprintf(&resultFile, "%s/%s%s.result", + abs_srcdir, pathprefix, data->name) < 0) goto cleanup; if (!(nodenames =3D virStringSplit(data->nodenames, ",", 0))) goto cleanup; - if (virTestLoadFile(namedNodesFile, &namedNodesStr) < 0) - goto cleanup; - - if (!(namedNodesJson =3D virJSONValueFromString(namedNodesStr))) + if (!(namedNodesJson =3D virTestLoadFileJSON(pathprefix, data->name, + "-named-nodes.json", NULL))) goto cleanup; if (!(nodedata =3D qemuBlockNodeNameGetBackingChain(namedNodesJson))) @@ -2783,9 +2776,7 @@ testBlockNodeNameDetect(const void *opaque) ret =3D 0; cleanup: - VIR_FREE(namedNodesFile); VIR_FREE(resultFile); - VIR_FREE(namedNodesStr); VIR_FREE(actual); virHashFree(nodedata); virStringListFree(nodenames); --=20 2.13.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list