From nobody Sat Feb 7 09:29:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1635776220; cv=none; d=zohomail.com; s=zohoarc; b=gde/M7sCtAnksHRmcvyq3D18DArT1r1FiJKfTM8t847jDqx6iqcJ81pwy9ZOkYvARaFdMCfZHNNsrtUr3eqZGjQAuXM+peXWWYyf91pUMjk551oSxt2UZSM55EpzeWxUqcdKO3C3f8JgZWOtYtdGOBdzxmj77hpCG/pRZPi5Qyk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635776220; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CAKWW9WugpwCT/EoQmUql1wOtlJEN9dcAiyey8fw0vg=; b=bsQv7kSMJkFG0sR8VTYL9zCtmv20bBVnHhIJDjQv/yujY1ItL4bGAeFDiUM6uNwJvUu2Q5X2rnC/yUPkDPwMN2P7E5313x4tjwgH0zCjLECyjqcgNKyxl1GeG8fyD8tImcZ/878bjKagrPdg7+gyBTfSfjPeTPUwck/VlvNen3U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1635776220665243.31341079233994; Mon, 1 Nov 2021 07:17:00 -0700 (PDT) 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-167-7nb9uHAOMbuqAyL40CezAQ-1; Mon, 01 Nov 2021 10:16:57 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C87FB18125DF; Mon, 1 Nov 2021 14:16:51 +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 4347E70958; Mon, 1 Nov 2021 14:16:51 +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 02ECB4EA3C; Mon, 1 Nov 2021 14:16:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A1EGYvk023126 for ; Mon, 1 Nov 2021 10:16:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5277560C0F; Mon, 1 Nov 2021 14:16:34 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id A737160C17 for ; Mon, 1 Nov 2021 14:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635776219; 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=CAKWW9WugpwCT/EoQmUql1wOtlJEN9dcAiyey8fw0vg=; b=g4bMxlrlILMb+4gAEPeZRqrs0VEXor00xeNCc6Hv54wZaxGv+ghOd0zm60lFvXUEWlrMIA iOdWQc4EhDQB8bXPCoHeZklmYxN+jTiNN53ZUp2+b8XDCMCPXeEsyBKA1JQ7gmnTZEVYJ8 FWNtrtU73LRm37qn60d3Ip/Vg2xhzco= X-MC-Unique: 7nb9uHAOMbuqAyL40CezAQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 7/7] tests: Drop cleanup/error labels Date: Mon, 1 Nov 2021 15:16:19 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1635776222643100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik --- tests/qemuagenttest.c | 216 +++++++++++++++-------------------- tests/qemucapabilitiestest.c | 19 ++- tests/qemumigparamstest.c | 34 +++--- tests/qemumonitorjsontest.c | 67 +++++------ tests/qemumonitortestutils.c | 32 ++---- 5 files changed, 149 insertions(+), 219 deletions(-) diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c index 479f4c0503..6a5aa3edd2 100644 --- a/tests/qemuagenttest.c +++ b/tests/qemuagenttest.c @@ -111,48 +111,45 @@ testQemuAgentFSFreeze(const void *data) virDomainXMLOption *xmlopt =3D (virDomainXMLOption *)data; g_autoptr(qemuMonitorTest) test =3D qemuMonitorTestNewAgent(xmlopt); const char *mountpoints[] =3D {"/fs1", "/fs2", "/fs3", "/fs4", "/fs5"}; - int ret =3D -1; + int rc; =20 if (!test) return -1; =20 if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddItem(test, "guest-fsfreeze-freeze-list", "{ \"return\" : 5 }") < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddItem(test, "guest-fsfreeze-freeze", "{ \"return\" : 7 }") < 0) - goto cleanup; + return -1; =20 - if ((ret =3D qemuAgentFSFreeze(qemuMonitorTestGetAgent(test), - mountpoints, 5)) < 0) - goto cleanup; + if ((rc =3D qemuAgentFSFreeze(qemuMonitorTestGetAgent(test), + mountpoints, 5)) < 0) + return -1; =20 - if (ret !=3D 5) { + if (rc !=3D 5) { virReportError(VIR_ERR_INTERNAL_ERROR, - "expected 5 frozen filesystems, got %d", ret); - goto cleanup; + "expected 5 frozen filesystems, got %d", rc); + return -1; } =20 - if ((ret =3D qemuAgentFSFreeze(qemuMonitorTestGetAgent(test), NULL, 0)= ) < 0) - goto cleanup; + if ((rc =3D qemuAgentFSFreeze(qemuMonitorTestGetAgent(test), NULL, 0))= < 0) + return -1; =20 - if (ret !=3D 7) { + if (rc !=3D 7) { virReportError(VIR_ERR_INTERNAL_ERROR, - "expected 7 frozen filesystems, got %d", ret); - goto cleanup; + "expected 7 frozen filesystems, got %d", rc); + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -161,47 +158,44 @@ testQemuAgentFSThaw(const void *data) { virDomainXMLOption *xmlopt =3D (virDomainXMLOption *)data; g_autoptr(qemuMonitorTest) test =3D qemuMonitorTestNewAgent(xmlopt); - int ret =3D -1; + int rc; =20 if (!test) return -1; =20 if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddItem(test, "guest-fsfreeze-thaw", "{ \"return\" : 5 }") < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddItem(test, "guest-fsfreeze-thaw", "{ \"return\" : 7 }") < 0) - goto cleanup; + return -1; =20 - if ((ret =3D qemuAgentFSThaw(qemuMonitorTestGetAgent(test))) < 0) - goto cleanup; + if ((rc =3D qemuAgentFSThaw(qemuMonitorTestGetAgent(test))) < 0) + return -1; =20 - if (ret !=3D 5) { + if (rc !=3D 5) { virReportError(VIR_ERR_INTERNAL_ERROR, - "expected 5 thawed filesystems, got %d", ret); - goto cleanup; + "expected 5 thawed filesystems, got %d", rc); + return -1; } =20 - if ((ret =3D qemuAgentFSThaw(qemuMonitorTestGetAgent(test))) < 0) - goto cleanup; + if ((rc =3D qemuAgentFSThaw(qemuMonitorTestGetAgent(test))) < 0) + return -1; =20 - if (ret !=3D 7) { + if (rc !=3D 7) { virReportError(VIR_ERR_INTERNAL_ERROR, - "expected 7 thawed filesystems, got %d", ret); - goto cleanup; + "expected 7 thawed filesystems, got %d", rc); + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -210,27 +204,23 @@ testQemuAgentFSTrim(const void *data) { virDomainXMLOption *xmlopt =3D (virDomainXMLOption *)data; g_autoptr(qemuMonitorTest) test =3D qemuMonitorTestNewAgent(xmlopt); - int ret =3D -1; =20 if (!test) return -1; =20 if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddItemParams(test, "guest-fstrim", "{ \"return\" : {} }", "minimum", "1337", NULL) < 0) - goto cleanup; + return -1; =20 if (qemuAgentFSTrim(qemuMonitorTestGetAgent(test), 1337) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -239,7 +229,6 @@ testQemuAgentGetFSInfoCommon(virDomainXMLOption *xmlopt, qemuMonitorTest **test, virDomainDef **def) { - int ret =3D -1; g_autofree char *domain_filename =3D NULL; g_autoptr(qemuMonitorTest) ret_test =3D NULL; g_autoptr(virDomainDef) ret_def =3D NULL; @@ -254,10 +243,10 @@ testQemuAgentGetFSInfoCommon(virDomainXMLOption *xmlo= pt, =20 if (!(ret_def =3D virDomainDefParseFile(domain_filename, xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACT= IVE))) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddAgentSyncResponse(ret_test) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddItem(ret_test, "guest-get-fsinfo", "{\"return\": [" @@ -293,14 +282,11 @@ testQemuAgentGetFSInfoCommon(virDomainXMLOption *xmlo= pt, " {\"name\": \"sdb1\"," " \"mountpoint\": \"/mnt/disk\"," " \"disk\": [], \"type\": \"xfs\"}]}") < = 0) - goto cleanup; + return -1; =20 *test =3D g_steal_pointer(&ret_test); *def =3D g_steal_pointer(&ret_def); - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int @@ -408,43 +394,39 @@ testQemuAgentSuspend(const void *data) { virDomainXMLOption *xmlopt =3D (virDomainXMLOption *)data; g_autoptr(qemuMonitorTest) test =3D qemuMonitorTestNewAgent(xmlopt); - int ret =3D -1; size_t i; =20 if (!test) return -1; =20 if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddItem(test, "guest-suspend-ram", "{ \"return\" : {} }") < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddItem(test, "guest-suspend-disk", "{ \"return\" : {} }") < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddItem(test, "guest-suspend-hybrid", "{ \"return\" : {} }") < 0) - goto cleanup; + return -1; =20 /* try the commands - fail if ordering changes */ for (i =3D 0; i < VIR_NODE_SUSPEND_TARGET_LAST; i++) { if (qemuAgentSuspend(qemuMonitorTestGetAgent(test), i) < 0) - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -506,13 +488,12 @@ testQemuAgentShutdown(const void *data) virDomainXMLOption *xmlopt =3D (virDomainXMLOption *)data; g_autoptr(qemuMonitorTest) test =3D qemuMonitorTestNewAgent(xmlopt); struct qemuAgentShutdownTestData priv; - int ret =3D -1; =20 if (!test) return -1; =20 if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; =20 priv.event =3D QEMU_AGENT_EVENT_SHUTDOWN; priv.mode =3D "halt"; @@ -520,14 +501,14 @@ testQemuAgentShutdown(const void *data) if (qemuMonitorTestAddHandler(test, "guest-shutdown", qemuAgentShutdownTestMonitorHandler, &priv, NULL) < 0) - goto cleanup; + return -1; =20 if (qemuAgentShutdown(qemuMonitorTestGetAgent(test), QEMU_AGENT_SHUTDOWN_HALT) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; =20 priv.event =3D QEMU_AGENT_EVENT_SHUTDOWN; priv.mode =3D "powerdown"; @@ -535,14 +516,14 @@ testQemuAgentShutdown(const void *data) if (qemuMonitorTestAddHandler(test, "guest-shutdown", qemuAgentShutdownTestMonitorHandler, &priv, NULL) < 0) - goto cleanup; + return -1; =20 if (qemuAgentShutdown(qemuMonitorTestGetAgent(test), QEMU_AGENT_SHUTDOWN_POWERDOWN) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; =20 priv.event =3D QEMU_AGENT_EVENT_RESET; priv.mode =3D "reboot"; @@ -551,17 +532,17 @@ testQemuAgentShutdown(const void *data) "guest-shutdown", qemuAgentShutdownTestMonitorHandler, &priv, NULL) < 0) - goto cleanup; + return -1; =20 if (qemuAgentShutdown(qemuMonitorTestGetAgent(test), QEMU_AGENT_SHUTDOWN_REBOOT) < 0) - goto cleanup; + return -1; =20 /* check negative response, so that we can verify that the agent breaks * out from sleep */ =20 if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddItem(test, "guest-shutdown", "{\"error\":" @@ -571,19 +552,16 @@ testQemuAgentShutdown(const void *data) " \"data\":{\"name\":\"guest-shutdown\"= }" " }" "}") < 0) - goto cleanup; + return -1; =20 if (qemuAgentShutdown(qemuMonitorTestGetAgent(test), QEMU_AGENT_SHUTDOWN_REBOOT) !=3D -1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", "agent shutdown command should have failed"); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -626,75 +604,71 @@ testQemuAgentCPU(const void *data) g_autoptr(qemuMonitorTest) test =3D qemuMonitorTestNewAgent(xmlopt); g_autofree qemuAgentCPUInfo *cpuinfo =3D NULL; int nvcpus; - int ret =3D -1; =20 if (!test) return -1; =20 if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddItem(test, "guest-get-vcpus", testQemuAgentCPUResponse) < 0) - goto cleanup; + return -1; =20 /* get cpus */ if ((nvcpus =3D qemuAgentGetVCPUs(qemuMonitorTestGetAgent(test), &cpuinfo)) < 0) - goto cleanup; + return -1; =20 if (nvcpus !=3D 4) { virReportError(VIR_ERR_INTERNAL_ERROR, "Expected '4' cpus, got '%d'", nvcpus); - goto cleanup; + return -1; } =20 /* try to unplug one */ if (qemuAgentUpdateCPUInfo(2, cpuinfo, nvcpus) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddItemParams(test, "guest-set-vcpus", "{ \"return\" : 1 }", "vcpus", testQemuAgentCPUArguments1, NULL) < 0) - goto cleanup; + return -1; =20 if (qemuAgentSetVCPUs(qemuMonitorTestGetAgent(test), cpuinfo, nvcpus) = < 0) - goto cleanup; + return -1; =20 /* try to hotplug two, second one will fail */ if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddItemParams(test, "guest-set-vcpus", "{ \"return\" : 1 }", "vcpus", testQemuAgentCPUArguments2, NULL) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddItemParams(test, "guest-set-vcpus", "{ \"error\" : \"random error\" }", "vcpus", testQemuAgentCPUArguments3, NULL) < 0) - goto cleanup; + return -1; =20 if (qemuAgentUpdateCPUInfo(4, cpuinfo, nvcpus) < 0) - goto cleanup; + return -1; =20 /* this should fail */ if (qemuAgentSetVCPUs(qemuMonitorTestGetAgent(test), cpuinfo, nvcpus) = !=3D -1) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -706,37 +680,33 @@ testQemuAgentArbitraryCommand(const void *data) { virDomainXMLOption *xmlopt =3D (virDomainXMLOption *)data; g_autoptr(qemuMonitorTest) test =3D qemuMonitorTestNewAgent(xmlopt); - int ret =3D -1; g_autofree char *reply =3D NULL; =20 if (!test) return -1; =20 if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddItem(test, "ble", testQemuAgentArbitraryCommandResponse) < 0) - goto cleanup; + return -1; =20 if (qemuAgentArbitraryCommand(qemuMonitorTestGetAgent(test), "{\"execute\":\"ble\"}", &reply, VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) - goto cleanup; + return -1; =20 if (STRNEQ(reply, testQemuAgentArbitraryCommandResponse)) { virReportError(VIR_ERR_INTERNAL_ERROR, "invalid processing of guest agent reply: " "got '%s' expected '%s'", reply, testQemuAgentArbitraryCommandResponse); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -755,36 +725,33 @@ testQemuAgentTimeout(const void *data) virDomainXMLOption *xmlopt =3D (virDomainXMLOption *)data; g_autoptr(qemuMonitorTest) test =3D qemuMonitorTestNewAgent(xmlopt); g_autofree char *reply =3D NULL; - int ret =3D -1; =20 if (!test) return -1; =20 - if (virTestGetExpensive() =3D=3D 0) { - ret =3D EXIT_AM_SKIP; - goto cleanup; - } + if (virTestGetExpensive() =3D=3D 0) + return EXIT_AM_SKIP; =20 if (qemuMonitorTestAddHandler(test, NULL, qemuAgentTimeoutTestMonitorHandler, NULL, NULL) < 0) - goto cleanup; + return -1; =20 if (qemuAgentFSFreeze(qemuMonitorTestGetAgent(test), NULL, 0) !=3D -1)= { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", "agent command should have failed"); - goto cleanup; + return -1; } =20 /* test timeout */ if (qemuMonitorTestAddAgentSyncResponse(test) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddHandler(test, NULL, qemuAgentTimeoutTestMonitorHandler, NULL, NULL) < 0) - goto cleanup; + return -1; =20 if (qemuAgentArbitraryCommand(qemuMonitorTestGetAgent(test), "{\"execute\":\"ble\"}", @@ -792,13 +759,10 @@ testQemuAgentTimeout(const void *data) 1) !=3D -2) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", "agent command didn't time out"); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static const char testQemuAgentGetInterfacesResponse[] =3D diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c index b866818e0a..99534ab9a1 100644 --- a/tests/qemucapabilitiestest.c +++ b/tests/qemucapabilitiestest.c @@ -68,7 +68,6 @@ testQemuDataReset(testQemuData *data) static int testQemuCaps(const void *opaque) { - int ret =3D -1; testQemuData *data =3D (void *) opaque; g_autofree char *repliesFile =3D NULL; g_autofree char *capsFile =3D NULL; @@ -88,10 +87,10 @@ testQemuCaps(const void *opaque) =20 if (!(mon =3D qemuMonitorTestNewFromFileFull(repliesFile, &data->drive= r, NULL, NULL))) - goto cleanup; + return -1; =20 if (qemuProcessQMPInitMonitor(qemuMonitorTestGetMonitor(mon)) < 0) - goto cleanup; + return -1; =20 binary =3D g_strdup_printf("/usr/bin/qemu-system-%s", data->archName); @@ -99,17 +98,17 @@ testQemuCaps(const void *opaque) if (!(capsActual =3D virQEMUCapsNewBinary(binary)) || virQEMUCapsInitQMPMonitor(capsActual, qemuMonitorTestGetMonitor(mon)) < 0) - goto cleanup; + return -1; =20 if (virQEMUCapsGet(capsActual, QEMU_CAPS_KVM)) { qemuMonitorResetCommandID(qemuMonitorTestGetMonitor(mon)); =20 if (qemuProcessQMPInitMonitor(qemuMonitorTestGetMonitor(mon)) < 0) - goto cleanup; + return -1; =20 if (virQEMUCapsInitQMPMonitorTCG(capsActual, qemuMonitorTestGetMonitor(mon)) <= 0) - goto cleanup; + return -1; =20 /* calculate fake microcode version based on filename for a reprod= ucible * number for testing which does not change with the contents */ @@ -125,14 +124,12 @@ testQemuCaps(const void *opaque) } =20 if (!(actual =3D virQEMUCapsFormatCache(capsActual))) - goto cleanup; + return -1; =20 if (virTestCompareToFile(actual, capsFile) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/qemumigparamstest.c b/tests/qemumigparamstest.c index 7d677e2b3a..ae59ff6757 100644 --- a/tests/qemumigparamstest.c +++ b/tests/qemumigparamstest.c @@ -100,7 +100,6 @@ qemuMigParamsTestXML(const void *opaque) g_autoptr(virJSONValue) params =3D NULL; g_autoptr(qemuMigrationParams) migParams =3D NULL; g_autofree char *actualXML =3D NULL; - int ret =3D -1; =20 replyFile =3D g_strdup_printf("%s/qemumigparamsdata/%s.reply", abs_srcdir, data->name); @@ -108,27 +107,24 @@ qemuMigParamsTestXML(const void *opaque) abs_srcdir, data->name); =20 if (!(mon =3D qemuMonitorTestNewFromFile(replyFile, data->xmlopt, true= ))) - goto cleanup; + return -1; =20 if (qemuMonitorGetMigrationParams(qemuMonitorTestGetMonitor(mon), ¶ms) < 0) - goto cleanup; + return -1; =20 if (!(migParams =3D qemuMigrationParamsFromJSON(params))) - goto cleanup; + return -1; =20 qemuMigParamsTestFormatXML(&buf, migParams); =20 if (!(actualXML =3D virBufferContentAndReset(&buf))) - goto cleanup; + return -1; =20 if (virTestCompareToFile(actualXML, xmlFile) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -144,7 +140,6 @@ qemuMigParamsTestJSON(const void *opaque) g_autoptr(qemuMigrationParams) migParams =3D NULL; g_autofree char *actualJSON =3D NULL; g_auto(virBuffer) debug =3D VIR_BUFFER_INITIALIZER; - int ret =3D -1; =20 replyFile =3D g_strdup_printf("%s/qemumigparamsdata/%s.reply", abs_srcdir, data->name); @@ -152,18 +147,18 @@ qemuMigParamsTestJSON(const void *opaque) abs_srcdir, data->name); =20 if (!(mon =3D qemuMonitorTestNewFromFile(replyFile, data->xmlopt, true= ))) - goto cleanup; + return -1; =20 if (qemuMonitorGetMigrationParams(qemuMonitorTestGetMonitor(mon), ¶msIn) < 0) - goto cleanup; + return -1; =20 if (!(migParams =3D qemuMigrationParamsFromJSON(paramsIn))) - goto cleanup; + return -1; =20 if (!(paramsOut =3D qemuMigrationParamsToJSON(migParams)) || !(actualJSON =3D virJSONValueToString(paramsOut, true))) - goto cleanup; + return -1; =20 if (testQEMUSchemaValidateCommand("migrate-set-parameters", paramsOut, @@ -174,16 +169,13 @@ qemuMigParamsTestJSON(const void *opaque) &debug) < 0) { VIR_TEST_VERBOSE("failed to validate migration params '%s' against= QMP schema: %s", actualJSON, virBufferCurrentContent(&debug)); - goto cleanup; + return -1; } =20 if (virTestCompareToFile(actualJSON, jsonFile) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index e4bc656308..8e552a4b20 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -243,7 +243,6 @@ testQemuMonitorJSONGetVersion(const void *opaque) { const testGenericData *data =3D opaque; virDomainXMLOption *xmlopt =3D data->xmlopt; - int ret =3D -1; int major; int minor; int micro; @@ -264,7 +263,7 @@ testQemuMonitorJSONGetVersion(const void *opaque) " \"package\":\"\"" " }" "}") < 0) - goto cleanup; + return -1; =20 if (qemuMonitorTestAddItem(test, "query-version", "{ " @@ -277,67 +276,64 @@ testQemuMonitorJSONGetVersion(const void *opaque) " \"package\":\"2.283.el6\"" " }" "}") < 0) - goto cleanup; + return -1; =20 if (qemuMonitorGetVersion(qemuMonitorTestGetMonitor(test), &major, &minor, µ, &package) < 0) - goto cleanup; + return -1; =20 if (major !=3D 1) { virReportError(VIR_ERR_INTERNAL_ERROR, "Major %d was not 1", major); - goto cleanup; + return -1; } if (minor !=3D 2) { virReportError(VIR_ERR_INTERNAL_ERROR, "Minor %d was not 2", major); - goto cleanup; + return -1; } if (micro !=3D 3) { virReportError(VIR_ERR_INTERNAL_ERROR, "Micro %d was not 3", major); - goto cleanup; + return -1; } =20 if (STRNEQ(package, "")) { virReportError(VIR_ERR_INTERNAL_ERROR, "Package %s was not ''", package); - goto cleanup; + return -1; } VIR_FREE(package); =20 if (qemuMonitorGetVersion(qemuMonitorTestGetMonitor(test), &major, &minor, µ, &package) < 0) - goto cleanup; + return -1; =20 if (major !=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "Major %d was not 0", major); - goto cleanup; + return -1; } if (minor !=3D 11) { virReportError(VIR_ERR_INTERNAL_ERROR, "Minor %d was not 11", major); - goto cleanup; + return -1; } if (micro !=3D 6) { virReportError(VIR_ERR_INTERNAL_ERROR, "Micro %d was not 6", major); - goto cleanup; + return -1; } =20 if (STRNEQ(package, "2.283.el6")) { virReportError(VIR_ERR_INTERNAL_ERROR, "Package %s was not '2.283.el6'", package); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int @@ -652,10 +648,9 @@ qemuMonitorJSONTestAttachOneChardev(virDomainXMLOption= *xmlopt, g_autoptr(qemuMonitorTest) test =3D qemuMonitorTestNewSchema(xmlopt, s= chema); g_autofree char *jsonreply =3D NULL; g_autofree char *fulllabel =3D NULL; - int ret =3D -1; =20 if (!test) - goto cleanup; + return -1; =20 if (!reply) reply =3D ""; @@ -668,7 +663,7 @@ qemuMonitorJSONTestAttachOneChardev(virDomainXMLOption = *xmlopt, =20 if (qemuMonitorTestAddItemExpect(test, "chardev-add", expectargs, true, jsonreply) < 0) - goto cleanup; + return -1; =20 data.chr =3D chr; data.fail =3D fail; @@ -676,12 +671,9 @@ qemuMonitorJSONTestAttachOneChardev(virDomainXMLOption= *xmlopt, data.test =3D test; =20 if (virTestRun(fulllabel, &testQemuMonitorJSONAttachChardev, &data) < = 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int @@ -1028,15 +1020,15 @@ testQemuMonitorJSONGetDeviceAliases(const void *opa= que) " \"type\": \"child\"}," " {\"name\": \"type\", \"type\": \"string\"= }" "]}") < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONGetDeviceAliases(qemuMonitorTestGetMonitor(test), &aliases) < 0) - goto cleanup; + return -1; =20 if (!aliases) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", "no aliases returned"= ); - goto cleanup; + return -1; } =20 ret =3D 0; @@ -1053,7 +1045,6 @@ testQemuMonitorJSONGetDeviceAliases(const void *opaqu= e) } } =20 - cleanup: return ret; } =20 @@ -2840,7 +2831,6 @@ testQemuMonitorJSONqemuMonitorJSONGetCPUModelBaseline= (const void *opaque) g_autoptr(virCPUDef) cpu_a =3D virCPUDefNew(); g_autoptr(virCPUDef) cpu_b =3D virCPUDefNew(); g_autoptr(qemuMonitorCPUModelInfo) baseline =3D NULL; - int ret =3D -1; =20 if (!(test =3D qemuMonitorTestNewSchema(data->xmlopt, data->schema))) return -1; @@ -2865,26 +2855,26 @@ testQemuMonitorJSONqemuMonitorJSONGetCPUModelBaseli= ne(const void *opaque) if (virCPUDefAddFeature(cpu_a, "feat_a", VIR_CPU_FEATURE_REQUIRE) < 0 = || virCPUDefAddFeature(cpu_a, "feat_b", VIR_CPU_FEATURE_REQUIRE) < 0 = || virCPUDefAddFeature(cpu_a, "feat_c", VIR_CPU_FEATURE_REQUIRE) < 0) - goto cleanup; + return -1; =20 if (qemuMonitorJSONGetCPUModelBaseline(qemuMonitorTestGetMonitor(test), cpu_a, cpu_b, &baseline) < 0) - goto cleanup; + return -1; =20 if (!baseline) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", "Baseline missing result"); - goto cleanup; + return -1; } if (!baseline->name) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", "Baseline missing model name"); - goto cleanup; + return -1; } if (baseline->nprops !=3D 2) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", "Baseline missing properties"); - goto cleanup; + return -1; } if (STRNEQ(baseline->props[0].name, "feat_a") || !baseline->props[0].value.boolean || @@ -2892,13 +2882,10 @@ testQemuMonitorJSONqemuMonitorJSONGetCPUModelBaseli= ne(const void *opaque) baseline->props[1].value.boolean) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", "Baseline property error"); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 2ca17f7f48..0d99b45909 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -1014,7 +1014,7 @@ qemuMonitorCommonTestNew(virDomainXMLOption *xmlopt, if (!(test->tmpdir =3D g_mkdtemp(tmpdir_template))) { virReportSystemError(errno, "%s", "Failed to create temporary directory"); - goto error; + return NULL; } =20 tmpdir_template =3D NULL; @@ -1026,14 +1026,14 @@ qemuMonitorCommonTestNew(virDomainXMLOption *xmlopt, } else { test->vm =3D virDomainObjNew(xmlopt); if (!test->vm) - goto error; + return NULL; if (!(test->vm->def =3D virDomainDefNew(xmlopt))) - goto error; + return NULL; } =20 if (virNetSocketNewListenUNIX(path, 0700, geteuid(), getegid(), &test->server) < 0) - goto error; + return NULL; =20 memset(src, 0, sizeof(*src)); src->type =3D VIR_DOMAIN_CHR_TYPE_UNIX; @@ -1042,13 +1042,9 @@ qemuMonitorCommonTestNew(virDomainXMLOption *xmlopt, path =3D NULL; =20 if (virNetSocketListen(test->server, 1) < 0) - goto error; + return NULL; =20 return g_steal_pointer(&test); - - error: - return NULL; - } =20 =20 @@ -1200,12 +1196,12 @@ qemuMonitorTestNewFromFile(const char *fileName, =20 if (test) { if (qemuMonitorTestAddItem(test, NULL, singleReply) < 0) - goto error; + return NULL; } else { /* Create new mocked monitor with our greeting */ if (!(test =3D qemuMonitorTestNew(xmlopt, NULL, NULL, singleReply, NULL))) - goto error; + return NULL; } =20 if (!eof) { @@ -1220,12 +1216,9 @@ qemuMonitorTestNewFromFile(const char *fileName, } =20 if (test && qemuMonitorTestAddItem(test, NULL, singleReply) < 0) - goto error; + return NULL; =20 return g_steal_pointer(&test); - - error: - return NULL; } =20 =20 @@ -1344,7 +1337,7 @@ qemuMonitorTestNewFromFileFull(const char *fileName, if (response) { if (qemuMonitorTestFullAddItem(ret, fileName, command, response, commandln) < 0) - goto error; + return NULL; command =3D NULL; response =3D NULL; } @@ -1364,18 +1357,15 @@ qemuMonitorTestNewFromFileFull(const char *fileName, if (!response) { virReportError(VIR_ERR_INTERNAL_ERROR, "missing response for c= ommand " "on line '%zu' in '%s'", commandln, fileName); - goto error; + return NULL; } =20 if (qemuMonitorTestFullAddItem(ret, fileName, command, response, commandln) < 0) - goto error; + return NULL; } =20 return g_steal_pointer(&ret); - - error: - return NULL; } =20 =20 --=20 2.32.0