From nobody Fri Apr 26 23:34:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1581211993412353.7693179702551; Sat, 8 Feb 2020 17:33:13 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-338-VwD_fHb7NQS9UDZxB3fSPw-1; Sat, 08 Feb 2020 20:33:04 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1C052DB22; Sun, 9 Feb 2020 01:32:57 +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 BC6AA5DA81; Sun, 9 Feb 2020 01:32: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 82C07866BB; Sun, 9 Feb 2020 01:32:52 +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 0191WooZ021153 for ; Sat, 8 Feb 2020 20:32:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id B3A1A5C28F; Sun, 9 Feb 2020 01:32:50 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-20.brq.redhat.com [10.40.200.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id E03F15C21B for ; Sun, 9 Feb 2020 01:32:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581211991; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=KXR4R8pUNJBr669HZ4qPdpKJKXPTMF2IKyS9z8xs98o=; b=inc8R+gVKpPIh/ith/3o0ai0FA9e2h1830d7SdbFUHETf4ExeSIK/iozi8G544A2aSXsSg 0zyRiVp9gHfN/bnixLW2r/5e1tqJ2qNjbbtSN4pviRH+y1BHWkwmBxS4pOs9onKj9eTgMy 4+I3oqLDHRKILOo5fJGqJ/uvLIoOOVg= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/7] testutils: check return value of g_setenv Date: Sun, 9 Feb 2020 02:32:31 +0100 Message-Id: <3c7b754941ff00ac915a634556c6cd77e1cb997d.1581211907.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 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: VwD_fHb7NQS9UDZxB3fSPw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The function returns gboolean. Compare against the FALSE value from GLib. Signed-off-by: J=C3=A1n Tomko Fixes: 2c3353242337bb50fe5abc9454fd5fc98236d4ef Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/testutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testutils.c b/tests/testutils.c index 0cf0ac7e5c..83daed8940 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -836,7 +836,7 @@ virTestSetEnvPath(void) } =20 if (new_path && - g_setenv("PATH", new_path, TRUE) < 0) + g_setenv("PATH", new_path, TRUE) =3D=3D FALSE) goto cleanup; =20 ret =3D 0; --=20 2.21.1 From nobody Fri Apr 26 23:34:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1581211985964482.95849462076774; Sat, 8 Feb 2020 17:33:05 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-132-P3s-4UFcMmuTEvsWr25a_g-1; Sat, 08 Feb 2020 20:33:02 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 16D388018A2; Sun, 9 Feb 2020 01:32:57 +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 AA78B86458; Sun, 9 Feb 2020 01:32: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 078CC1809565; Sun, 9 Feb 2020 01:32:52 +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 0191WpjL021160 for ; Sat, 8 Feb 2020 20:32:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id EB8AD5C21B; Sun, 9 Feb 2020 01:32:51 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-20.brq.redhat.com [10.40.200.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DC335C28F for ; Sun, 9 Feb 2020 01:32:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581211984; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=hcO5S5bfH3J9eykVFvS8ei0Dd9RUUjJKNTo2UCMj42U=; b=V5/qM1UhF78OxpvFEt4It1w83RXftGAI6izI3FCyDEG3hnYyj2W01y7j9jpWEIxiNNrt7l 4tUDLT7gWfJ1bYH+R+SivE2TXtJYBgUSYgEiRd4IiNzjfgaHN56LXvT5ZZOoWiZ8FS24+s 9Bwh6tCLNR5Bg7Yp1rPav5Ncy6uytu8= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/7] testutils: use g_autofree Date: Sun, 9 Feb 2020 02:32:32 +0100 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 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: P3s-4UFcMmuTEvsWr25a_g-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: J=C3=A1n Tomko Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/testutils.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/tests/testutils.c b/tests/testutils.c index 83daed8940..75cba98eb3 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -279,7 +279,7 @@ virTestLoadFileGetPath(const char *p, char * virTestLoadFilePath(const char *p, ...) { - char *path =3D NULL; + g_autofree char *path =3D NULL; char *ret =3D NULL; va_list ap; =20 @@ -292,7 +292,6 @@ virTestLoadFilePath(const char *p, ...) =20 cleanup: va_end(ap); - VIR_FREE(path); =20 return ret; } @@ -309,8 +308,8 @@ virJSONValuePtr virTestLoadFileJSON(const char *p, ...) { virJSONValuePtr ret =3D NULL; - char *jsonstr =3D NULL; - char *path =3D NULL; + g_autofree char *jsonstr =3D NULL; + g_autofree char *path =3D NULL; va_list ap; =20 va_start(ap, p); @@ -326,8 +325,6 @@ virTestLoadFileJSON(const char *p, ...) =20 cleanup: va_end(ap); - VIR_FREE(jsonstr); - VIR_FREE(path); return ret; } =20 @@ -420,7 +417,7 @@ static int virTestRewrapFile(const char *filename) { int ret =3D -1; - char *script =3D NULL; + g_autofree char *script =3D NULL; virCommandPtr cmd =3D NULL; =20 if (!(virStringHasSuffix(filename, ".args") || @@ -435,7 +432,6 @@ virTestRewrapFile(const char *filename) =20 ret =3D 0; cleanup: - VIR_FREE(script); virCommandFree(cmd); return ret; } @@ -669,8 +665,8 @@ virTestCompareToFile(const char *actual, const char *filename) { int ret =3D -1; - char *filecontent =3D NULL; - char *fixedcontent =3D NULL; + g_autofree char *filecontent =3D NULL; + g_autofree char *fixedcontent =3D NULL; const char *cmpcontent =3D actual; =20 if (!cmpcontent) @@ -700,8 +696,6 @@ virTestCompareToFile(const char *actual, =20 ret =3D 0; failure: - VIR_FREE(fixedcontent); - VIR_FREE(filecontent); return ret; } =20 @@ -826,7 +820,7 @@ virTestSetEnvPath(void) { int ret =3D -1; const char *path =3D getenv("PATH"); - char *new_path =3D NULL; + g_autofree char *new_path =3D NULL; =20 if (path) { if (strstr(path, abs_builddir) !=3D path) @@ -841,7 +835,6 @@ virTestSetEnvPath(void) =20 ret =3D 0; cleanup: - VIR_FREE(new_path); return ret; } =20 @@ -1045,15 +1038,13 @@ virCapsPtr virTestGenericCapsInit(void) =20 =20 if (virTestGetDebug() > 1) { - char *caps_str; + g_autofree char *caps_str =3D NULL; =20 caps_str =3D virCapabilitiesFormatXML(caps); if (!caps_str) goto error; =20 VIR_TEST_DEBUG("Generic driver capabilities:\n%s", caps_str); - - VIR_FREE(caps_str); } =20 return caps; @@ -1131,7 +1122,7 @@ testCompareDomXML2XMLFiles(virCapsPtr caps G_GNUC_UNU= SED, unsigned int parseFlags, testCompareDomXML2XMLResult expectResult) { - char *actual =3D NULL; + g_autofree char *actual =3D NULL; int ret =3D -1; testCompareDomXML2XMLResult result; virDomainDefPtr def =3D NULL; @@ -1184,7 +1175,6 @@ testCompareDomXML2XMLFiles(virCapsPtr caps G_GNUC_UNU= SED, expectResult, result); } =20 - VIR_FREE(actual); virDomainDefFree(def); return ret; } --=20 2.21.1 From nobody Fri Apr 26 23:34:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1581212006466620.4119006142572; Sat, 8 Feb 2020 17:33:26 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-37-xsbe4jg9P8-3ZYBM6cbeGA-1; Sat, 08 Feb 2020 20:33:23 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 78C7BDB24; Sun, 9 Feb 2020 01:33:17 +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 52BE560BE1; Sun, 9 Feb 2020 01:33:17 +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 0DA48866C2; Sun, 9 Feb 2020 01:33:17 +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 0191WrAL021170 for ; Sat, 8 Feb 2020 20:32:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 625555C28F; Sun, 9 Feb 2020 01:32:53 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-20.brq.redhat.com [10.40.200.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7446C5C21B for ; Sun, 9 Feb 2020 01:32:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581212005; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=BIMhghQtDbu8MRObGVUES9A9ibZrRTHpfhqhef1OKQs=; b=P5Gs0cwwpN7P7546GZksOWCd1ZyEk5vaLxGiq2WBrZch5IhibwCxBzPKV+ertIidED2Z49 UkjnZGTkPTxJZXEDIVIpdxxH04ZnqhVDbqB7LNps0iU2NGq6FVpyIMoEr/h/V3Bk100k/9 3yIc4/S3XYoopPhGFLv85x8lashy8lo= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/7] testutils: use g_autoptr Date: Sun, 9 Feb 2020 02:32:33 +0100 Message-Id: <535abdabeb7a47f447ce22d313c53d747226ac1f.1581211907.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 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: xsbe4jg9P8-3ZYBM6cbeGA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use g_autoptr where possible. virTestCapsBuildNUMATopology is not converted completely, because while the VIR_FREE call on cell_cpus is technically wrong, neither VIR_ALLOC_N nor virBitmapNew can return an allocation error now so it is effectively dead code. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/testutils.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/testutils.c b/tests/testutils.c index 75cba98eb3..e9431b9b5f 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -418,7 +418,7 @@ virTestRewrapFile(const char *filename) { int ret =3D -1; g_autofree char *script =3D NULL; - virCommandPtr cmd =3D NULL; + g_autoptr(virCommand) cmd =3D NULL; =20 if (!(virStringHasSuffix(filename, ".args") || virStringHasSuffix(filename, ".ldargs"))) @@ -432,7 +432,6 @@ virTestRewrapFile(const char *filename) =20 ret =3D 0; cleanup: - virCommandFree(cmd); return ret; } =20 @@ -1001,7 +1000,7 @@ void virTestClearCommandPath(char *cmdset) =20 virCapsPtr virTestGenericCapsInit(void) { - virCapsPtr caps; + g_autoptr(virCaps) caps =3D NULL; virCapsGuestPtr guest; =20 if ((caps =3D virCapabilitiesNew(VIR_ARCH_X86_64, @@ -1047,10 +1046,9 @@ virCapsPtr virTestGenericCapsInit(void) VIR_TEST_DEBUG("Generic driver capabilities:\n%s", caps_str); } =20 - return caps; + return g_steal_pointer(&caps); =20 error: - virObjectUnref(caps); return NULL; } =20 @@ -1066,7 +1064,7 @@ virCapsPtr virTestGenericCapsInit(void) virCapsHostNUMAPtr virTestCapsBuildNUMATopology(int seq) { - virCapsHostNUMAPtr caps =3D virCapabilitiesHostNUMANew(); + g_autoptr(virCapsHostNUMA) caps =3D virCapabilitiesHostNUMANew(); virCapsHostNUMACellCPUPtr cell_cpus =3D NULL; int core_id, cell_id; int id; @@ -1096,10 +1094,9 @@ virTestCapsBuildNUMATopology(int seq) cell_cpus =3D NULL; } =20 - return caps; + return g_steal_pointer(&caps); =20 error: - virCapabilitiesHostNUMAUnref(caps); VIR_FREE(cell_cpus); return NULL; } --=20 2.21.1 From nobody Fri Apr 26 23:34:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1581212010359831.0413020512894; Sat, 8 Feb 2020 17:33:30 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-35-ovrY9l4kMfyBMqd4-Zc-Xg-1; Sat, 08 Feb 2020 20:33:27 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 17D048010F6; Sun, 9 Feb 2020 01:33:22 +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 E8FA610021B2; Sun, 9 Feb 2020 01:33:21 +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 B3DBA18089D0; Sun, 9 Feb 2020 01:33:21 +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 0191WspC021180 for ; Sat, 8 Feb 2020 20:32:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id B26945C21B; Sun, 9 Feb 2020 01:32:54 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-20.brq.redhat.com [10.40.200.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id E83575C28F for ; Sun, 9 Feb 2020 01:32:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581212009; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=D1KhVih01E+iowDxSbrgZyoSsTKoG8OYdJ9w+4wrUiM=; b=XwR8S8KizQJuurGEzAyPo0q6dMKzXxUPKYGuHWIb/uLh+QKv8mcRwK448oSklZGg1lGGOt P1qZhhrH6ZUY5kfmLCnNJV96blkdo65MWiRfFdvSRiYaHF72evvS8M8RegCI9qkFKyfgN5 lRMrjWRHLmJ2HeZCTVORGz9cMnzhnwU= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 4/7] testutils: remove unnecessary labels Date: Sun, 9 Feb 2020 02:32:34 +0100 Message-Id: <10f16eb595a8a65d6709ec57fad2157ebb1e4f8a.1581211907.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 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: ovrY9l4kMfyBMqd4-Zc-Xg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The cleanups made some labels redundant. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/testutils.c | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/tests/testutils.c b/tests/testutils.c index e9431b9b5f..a7a8a19fff 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -416,7 +416,6 @@ virTestCaptureProgramOutput(const char *const argv[] G_= GNUC_UNUSED, static int virTestRewrapFile(const char *filename) { - int ret =3D -1; g_autofree char *script =3D NULL; g_autoptr(virCommand) cmd =3D NULL; =20 @@ -428,11 +427,9 @@ virTestRewrapFile(const char *filename) =20 cmd =3D virCommandNewArgList(PYTHON, script, "--in-place", filename, N= ULL); if (virCommandRun(cmd, NULL) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 /** @@ -663,7 +660,6 @@ int virTestCompareToFile(const char *actual, const char *filename) { - int ret =3D -1; g_autofree char *filecontent =3D NULL; g_autofree char *fixedcontent =3D NULL; const char *cmpcontent =3D actual; @@ -672,7 +668,7 @@ virTestCompareToFile(const char *actual, cmpcontent =3D ""; =20 if (virTestLoadFile(filename, &filecontent) < 0 && !virTestGetRegenera= te()) - goto failure; + return -1; =20 if (filecontent) { size_t filecontentLen =3D strlen(filecontent); @@ -690,12 +686,10 @@ virTestCompareToFile(const char *actual, virTestDifferenceFull(stderr, filecontent, filename, cmpcontent, NULL); - goto failure; + return -1; } =20 - ret =3D 0; - failure: - return ret; + return 0; } =20 int @@ -817,7 +811,6 @@ virTestGetRegenerate(void) static int virTestSetEnvPath(void) { - int ret =3D -1; const char *path =3D getenv("PATH"); g_autofree char *new_path =3D NULL; =20 @@ -830,11 +823,9 @@ virTestSetEnvPath(void) =20 if (new_path && g_setenv("PATH", new_path, TRUE) =3D=3D FALSE) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 int virTestMain(int argc, @@ -1010,30 +1001,30 @@ virCapsPtr virTestGenericCapsInit(void) if ((guest =3D virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VI= R_ARCH_I686, "/usr/bin/acme-virt", NULL, 0, NULL)) =3D=3D NULL) - goto error; + return NULL; =20 if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_TEST, NULL, = NULL, 0, NULL)) - goto error; + return NULL; if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL)) - goto error; + return NULL; if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM, NULL, NULL, 0, NULL)) - goto error; + return NULL; =20 if ((guest =3D virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VI= R_ARCH_X86_64, "/usr/bin/acme-virt", NULL, 0, NULL)) =3D=3D NULL) - goto error; + return NULL; =20 if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_TEST, NULL, = NULL, 0, NULL)) - goto error; + return NULL; if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_QEMU, NULL, NULL, 0, NULL)) - goto error; + return NULL; if (!virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_KVM, NULL, NULL, 0, NULL)) - goto error; + return NULL; =20 =20 if (virTestGetDebug() > 1) { @@ -1041,15 +1032,12 @@ virCapsPtr virTestGenericCapsInit(void) =20 caps_str =3D virCapabilitiesFormatXML(caps); if (!caps_str) - goto error; + return NULL; =20 VIR_TEST_DEBUG("Generic driver capabilities:\n%s", caps_str); } =20 return g_steal_pointer(&caps); - - error: - return NULL; } =20 =20 --=20 2.21.1 From nobody Fri Apr 26 23:34:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 158121201669973.29140424667173; Sat, 8 Feb 2020 17:33:36 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-174-Di4jtkJbPTidYyDVkZt1eQ-1; Sat, 08 Feb 2020 20:33:33 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 87884184AEA8; Sun, 9 Feb 2020 01:33:26 +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 64C1D5DA7E; Sun, 9 Feb 2020 01:33:26 +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 170F218089D7; Sun, 9 Feb 2020 01:33:26 +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 0191WuXM021189 for ; Sat, 8 Feb 2020 20:32:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0F3F05C28F; Sun, 9 Feb 2020 01:32:56 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-20.brq.redhat.com [10.40.200.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B9FC5C21B for ; Sun, 9 Feb 2020 01:32:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581212015; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=1nFJ25jEJyL5EH9ihGPPU9NP/cT4WtYcXRJX70UytAU=; b=R2aRFkAqe/k2wUB1pFVfE0LUzcxYvFCRazXxFNVT1BLHpF7GbOaq1A0f5WGrNsWOz+SOny zZYuv7r1yIVQ2Mw4mwow+QkcVcqz15IH67Wf4O4pSrcZ80XWfy4SGnh6ePyX0oR+vozAIE XCxKKGXNkUXP/8m09qK6Zwd2Stblplw= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 5/7] virshtest: refactor testCompareOutputLit Date: Sun, 9 Feb 2020 02:32:35 +0100 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 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: Di4jtkJbPTidYyDVkZt1eQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use g_autofree and get rid of the cleanup label. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/virshtest.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/tests/virshtest.c b/tests/virshtest.c index 189238b826..83675710ea 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -60,26 +60,20 @@ static int testCompareOutputLit(const char *expectData, const char *filter, const char *const argv[]) { - int result =3D -1; - char *actualData =3D NULL; + g_autofree char *actualData =3D NULL; =20 if (virTestCaptureProgramOutput(argv, &actualData, 4096) < 0) - goto cleanup; + return -1; =20 if (filter && testFilterLine(actualData, filter) < 0) - goto cleanup; + return -1; =20 if (STRNEQ(expectData, actualData)) { virTestDifference(stderr, expectData, actualData); - goto cleanup; + return -1; } =20 - result =3D 0; - - cleanup: - VIR_FREE(actualData); - - return result; + return 0; } =20 # define VIRSH_DEFAULT abs_top_builddir "/tools/virsh", \ --=20 2.21.1 From nobody Fri Apr 26 23:34:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1581212009915671.3887203404429; Sat, 8 Feb 2020 17:33:29 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-112-N230KZllPW-R9unLT0m5jA-1; Sat, 08 Feb 2020 20:33:22 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 77C8EDB23; Sun, 9 Feb 2020 01:33:17 +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 512BB8680D; Sun, 9 Feb 2020 01:33:17 +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 0CE0B866C1; Sun, 9 Feb 2020 01:33:17 +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 0191WvN0021204 for ; Sat, 8 Feb 2020 20:32:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4F2015C21B; Sun, 9 Feb 2020 01:32:57 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-20.brq.redhat.com [10.40.200.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 965635C28F for ; Sun, 9 Feb 2020 01:32:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581212008; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ZeFiky3ugkCpJ4TuWdQrECfEjh0XjG4dNg0zrE/foHw=; b=KR7Rd12CTlnfnnD0Y7mmnMt5VDNIlF/RSG8Zt6VJ5nUJ2jI/kL+32ELJb9BUzBgd7noLgk g8don0dgSdrIwwkkj+j98aiwFKWIb0jck5GUdVS8Z7PPw5oKzE36ughwNi13mXxwX94w1j 6aqmP3nFf6y7aX0MpU+xeCHvnxk4JUc= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 6/7] virshtest: use virCommand instead of custom impl Date: Sun, 9 Feb 2020 02:32:36 +0100 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 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: N230KZllPW-R9unLT0m5jA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Our virCommand helper API already has the ability to capture program output, there's no need to open-code it. Apart from simplifying the code, the test is marginally faster due to recent improvements in virCommandMassClose. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/virshtest.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/virshtest.c b/tests/virshtest.c index 83675710ea..add33215b7 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -5,6 +5,7 @@ #include "internal.h" #include "virxml.h" #include "testutils.h" +#include "vircommand.h" #include "virstring.h" =20 #define VIR_FROM_THIS VIR_FROM_NONE @@ -61,10 +62,26 @@ testCompareOutputLit(const char *expectData, const char *filter, const char *const argv[]) { g_autofree char *actualData =3D NULL; + const char *empty =3D ""; + g_autoptr(virCommand) cmd =3D NULL; + g_autofree char *errbuf =3D NULL; =20 - if (virTestCaptureProgramOutput(argv, &actualData, 4096) < 0) + if (!(cmd =3D virCommandNewArgs(argv))) return -1; =20 + virCommandAddEnvString(cmd, "LANG=3DC"); + virCommandSetInputBuffer(cmd, empty); + virCommandSetOutputBuffer(cmd, &actualData); + virCommandSetErrorBuffer(cmd, &errbuf); + + if (virCommandRun(cmd, NULL) < 0) + return -1; + + if (STRNEQ(errbuf, "")) { + fprintf(stderr, "Command reported error: %s", errbuf); + return -1; + } + if (filter && testFilterLine(actualData, filter) < 0) return -1; =20 --=20 2.21.1 From nobody Fri Apr 26 23:34:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1581212006967872.6736058484112; Sat, 8 Feb 2020 17:33:26 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-428-lqJ9gbA3PWWLJtYiQGpjNw-1; Sat, 08 Feb 2020 20:33:22 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B3E838018A3; Sun, 9 Feb 2020 01:33:17 +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 864FE5DA82; Sun, 9 Feb 2020 01:33:17 +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 4D74B18089CE; Sun, 9 Feb 2020 01:33:17 +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 0191WxYg021223 for ; Sat, 8 Feb 2020 20:32:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id 38D3C5C28F; Sun, 9 Feb 2020 01:32:59 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-20.brq.redhat.com [10.40.200.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA9A15C21B for ; Sun, 9 Feb 2020 01:32:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581212005; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=u64QAK4OOWYG6Mil5SlUCC7pa4khi/dFKRwwwGj+Nhc=; b=fEO1OTIPxDnn3aGoplTsRXl4Td+BKKY7TVQsNQLaBg5XMxFAkqklY2Vu9HYtp/C1h0lDoO Bz1AREONMnvoir6P82AQLy0EKhftikk7UaNmJjJbqPYuFF0w1oD6YBDTPRsqQoZoj6qWwa VSuOiZuo80I8GWrFWRPTzC1DfquvFLQ= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 7/7] testutils: remove now unused virTestCaptureProgramOutput Date: Sun, 9 Feb 2020 02:32:37 +0100 Message-Id: <95b26ca1f0d20da2a8fac1b1a593aff97f196d1d.1581211907.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 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: lqJ9gbA3PWWLJtYiQGpjNw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: J=C3=A1n Tomko Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/testutils.c | 84 ----------------------------------------------- tests/testutils.h | 2 -- 2 files changed, 86 deletions(-) diff --git a/tests/testutils.c b/tests/testutils.c index a7a8a19fff..8326602c9c 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -329,90 +329,6 @@ virTestLoadFileJSON(const char *p, ...) } =20 =20 -#ifndef WIN32 -static -void virTestCaptureProgramExecChild(const char *const argv[], - int pipefd) -{ - size_t i; - int open_max; - int stdinfd =3D -1; - const char *const env[] =3D { - "LANG=3DC", - NULL - }; - - if ((stdinfd =3D open("/dev/null", O_RDONLY)) < 0) - goto cleanup; - - open_max =3D sysconf(_SC_OPEN_MAX); - if (open_max < 0) - goto cleanup; - - for (i =3D 0; i < open_max; i++) { - if (i !=3D stdinfd && - i !=3D pipefd) { - int tmpfd; - tmpfd =3D i; - VIR_FORCE_CLOSE(tmpfd); - } - } - - if (dup2(stdinfd, STDIN_FILENO) !=3D STDIN_FILENO) - goto cleanup; - if (dup2(pipefd, STDOUT_FILENO) !=3D STDOUT_FILENO) - goto cleanup; - if (dup2(pipefd, STDERR_FILENO) !=3D STDERR_FILENO) - goto cleanup; - - /* SUS is crazy here, hence the cast */ - execve(argv[0], (char *const*)argv, (char *const*)env); - - cleanup: - VIR_FORCE_CLOSE(stdinfd); -} - -int -virTestCaptureProgramOutput(const char *const argv[], char **buf, int maxl= en) -{ - int pipefd[2]; - int len; - - if (virPipeQuiet(pipefd) < 0) - return -1; - - pid_t pid =3D fork(); - switch (pid) { - case 0: - VIR_FORCE_CLOSE(pipefd[0]); - virTestCaptureProgramExecChild(argv, pipefd[1]); - - VIR_FORCE_CLOSE(pipefd[1]); - _exit(EXIT_FAILURE); - - case -1: - return -1; - - default: - VIR_FORCE_CLOSE(pipefd[1]); - len =3D virFileReadLimFD(pipefd[0], maxlen, buf); - VIR_FORCE_CLOSE(pipefd[0]); - if (virProcessWait(pid, NULL, false) < 0) - return -1; - - return len; - } -} -#else /* !WIN32 */ -int -virTestCaptureProgramOutput(const char *const argv[] G_GNUC_UNUSED, - char **buf G_GNUC_UNUSED, - int maxlen G_GNUC_UNUSED) -{ - return -1; -} -#endif /* !WIN32 */ - static int virTestRewrapFile(const char *filename) { diff --git a/tests/testutils.h b/tests/testutils.h index c1b365ab0d..3f32aa7200 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -46,8 +46,6 @@ char *virTestLoadFilePath(const char *p, ...) virJSONValuePtr virTestLoadFileJSON(const char *p, ...) G_GNUC_NULL_TERMINATED; =20 -int virTestCaptureProgramOutput(const char *const argv[], char **buf, int = maxlen); - void virTestClearCommandPath(char *cmdset); =20 int virTestDifference(FILE *stream, --=20 2.21.1