From nobody Sun Feb 8 17:04:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) client-ip=63.128.21.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 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=1595979675; cv=none; d=zohomail.com; s=zohoarc; b=fK6WjF04VK9RX6DBsiJZFAzSFd2Kba/qd2KF/KBJpl5xGxBnFV12MdYWgo8auuUDmUEr0K6olJqFsAaZxXM/Z17hO6qBADoA1B48hiuKQ9yavBHw9u9AwHaxtUgG6AqD0i0KUZGx0K4DErd5bsqY6TmXOLrn8Kk177tyS2w60HQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595979675; 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=rwpOrEIdcnJkSNCXhCUMWNlOBqXRVBX23BfgBJb6mCg=; b=mDZNRucTOaEU78ZZUfUFFv5f92L8mYJ4kC81xMInq/UgKy73R2cUZsm52cHfCzTWqXPoVXRLmqY5hb40WPLDbaKPwVXEUulXesCP47tw8GuPQjFNH3gQLAw2ANJVmqJ5y4hC0xll3NjHNfO8UfMu4QlWMIAd72JmvU1sWMOIJ3o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) by mx.zohomail.com with SMTPS id 1595979675255168.05247491530133; Tue, 28 Jul 2020 16:41:15 -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-432-AGGz-AbuPCy0eBky95N-sQ-1; Tue, 28 Jul 2020 19:41:11 -0400 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 6DB9B107BEF6; Tue, 28 Jul 2020 23:41:05 +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 4C788619C4; Tue, 28 Jul 2020 23:41:05 +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 1D5D01806B0D; Tue, 28 Jul 2020 23:41:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06SNf0vm003884 for ; Tue, 28 Jul 2020 19:41:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 24CF08A168; Tue, 28 Jul 2020 23:41:00 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 738D78A176 for ; Tue, 28 Jul 2020 23:40:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595979674; 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=rwpOrEIdcnJkSNCXhCUMWNlOBqXRVBX23BfgBJb6mCg=; b=g7Krb772XEYsNKCDP+tIT8oqfZ/LJtE9S7pv6auLK1czc24asdxM81ytBqd/1Dp3sKrQUz VwQiDAD7jSVsAXkXQbLb1J5dlbaMPQlUtSP9i1mBsjmj/u/bfcKmM3K5a1dPZb7cuDLl96 d+Ic2H29qrqSSJZYHSN4lz7zF1ZTO2w= X-MC-Unique: AGGz-AbuPCy0eBky95N-sQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 5/5] tests: commandtest: drop unnecessary labels Date: Wed, 29 Jul 2020 01:40:48 +0200 Message-Id: <4cd2610c0de48e6807c1bc15f200e217d9171a6d.1595979625.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: J=C3=A1n Tomko --- tests/commandtest.c | 106 +++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 70 deletions(-) diff --git a/tests/commandtest.c b/tests/commandtest.c index b0bf6f379a..42225a8ef2 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -97,20 +97,16 @@ static int checkoutput(const char *testname) static int test0(const void *unused G_GNUC_UNUSED) { g_autoptr(virCommand) cmd =3D NULL; - int ret =3D -1; =20 cmd =3D virCommandNew(abs_builddir "/commandhelper-doesnotexist"); if (virCommandRun(cmd, NULL) =3D=3D 0) - goto cleanup; + return -1; =20 if (virGetLastErrorCode() =3D=3D VIR_ERR_OK) - goto cleanup; + return -1; =20 virResetLastError(); - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 /* @@ -121,24 +117,21 @@ static int test0(const void *unused G_GNUC_UNUSED) static int test1(const void *unused G_GNUC_UNUSED) { g_autoptr(virCommand) cmd =3D NULL; - int ret =3D -1; int status; =20 cmd =3D virCommandNew(abs_builddir "/commandhelper-doesnotexist"); if (virCommandRun(cmd, &status) < 0) - goto cleanup; + return -1; if (status !=3D EXIT_ENOENT) - goto cleanup; + return -1; =20 virCommandRawStatus(cmd); if (virCommandRun(cmd, &status) < 0) - goto cleanup; + return -1; if (!WIFEXITED(status) || WEXITSTATUS(status) !=3D EXIT_ENOENT) - goto cleanup; - ret =3D 0; + return -1; =20 - cleanup: - return ret; + return 0; } =20 /* @@ -177,11 +170,10 @@ static int test3(const void *unused G_GNUC_UNUSED) VIR_AUTOCLOSE newfd2 =3D dup(STDERR_FILENO); int newfd3 =3D dup(STDERR_FILENO); struct stat before, after; - int ret =3D -1; =20 if (fstat(newfd3, &before) < 0) { perror("fstat"); - goto cleanup; + return -1; } virCommandPassFD(cmd, newfd1, 0); virCommandPassFD(cmd, newfd3, @@ -189,13 +181,13 @@ static int test3(const void *unused G_GNUC_UNUSED) =20 if (virCommandRun(cmd, NULL) < 0) { printf("Cannot run child %s\n", virGetLastErrorMessage()); - goto cleanup; + return -1; } =20 if (fcntl(newfd1, F_GETFL) < 0 || fcntl(newfd2, F_GETFL) < 0) { puts("fds 1/2 were not open"); - goto cleanup; + return -1; } =20 /* We expect newfd3 to be closed, but the @@ -211,14 +203,11 @@ static int test3(const void *unused G_GNUC_UNUSED) before.st_dev =3D=3D after.st_dev && before.st_mode =3D=3D after.st_mode) { puts("fd 3 should not be open"); - goto cleanup; + return -1; } } =20 - ret =3D checkoutput("test3"); - - cleanup: - return ret; + return checkoutput("test3"); } =20 =20 @@ -550,7 +539,6 @@ static int test15(const void *unused G_GNUC_UNUSED) { g_autoptr(virCommand) cmd =3D virCommandNew(abs_builddir "/commandhelp= er"); g_autofree char *cwd =3D NULL; - int ret =3D -1; =20 cwd =3D g_strdup_printf("%s/commanddata", abs_srcdir); virCommandSetWorkingDirectory(cmd, cwd); @@ -558,14 +546,10 @@ static int test15(const void *unused G_GNUC_UNUSED) =20 if (virCommandRun(cmd, NULL) < 0) { printf("Cannot run child %s\n", virGetLastErrorMessage()); - goto cleanup; + return -1; } =20 - ret =3D checkoutput("test15"); - - cleanup: - - return ret; + return checkoutput("test15"); } =20 /* @@ -576,7 +560,6 @@ static int test16(const void *unused G_GNUC_UNUSED) g_autoptr(virCommand) cmd =3D virCommandNew("true"); g_autofree char *outactual =3D NULL; const char *outexpect =3D "A=3DB C=3D'D E' true F 'G H'"; - int ret =3D -1; VIR_AUTOCLOSE fd =3D -1; =20 virCommandAddEnvPair(cmd, "A", "B"); @@ -586,28 +569,25 @@ static int test16(const void *unused G_GNUC_UNUSED) =20 if ((outactual =3D virCommandToString(cmd, false)) =3D=3D NULL) { printf("Cannot convert to string: %s\n", virGetLastErrorMessage()); - goto cleanup; + return -1; } if ((fd =3D open(abs_builddir "/commandhelper.log", O_CREAT | O_TRUNC | O_WRONLY, 0600)) < 0) { printf("Cannot open log file: %s\n", g_strerror(errno)); - goto cleanup; + return -1; } virCommandWriteArgLog(cmd, fd); if (VIR_CLOSE(fd) < 0) { printf("Cannot close log file: %s\n", g_strerror(errno)); - goto cleanup; + return -1; } =20 if (STRNEQ(outactual, outexpect)) { virTestDifference(stderr, outexpect, outactual); - goto cleanup; + return -1; } =20 - ret =3D checkoutput("test16"); - - cleanup: - return ret; + return checkoutput("test16"); } =20 /* @@ -715,32 +695,28 @@ static int test19(const void *unused G_GNUC_UNUSED) { g_autoptr(virCommand) cmd =3D virCommandNewArgList("sleep", "100", NUL= L); pid_t pid; - int ret =3D -1; =20 alarm(5); if (virCommandRunAsync(cmd, &pid) < 0) { printf("Cannot run child %s\n", virGetLastErrorMessage()); - goto cleanup; + return -1; } =20 if (kill(pid, 0) !=3D 0) { printf("Child should still be running"); - goto cleanup; + return -1; } =20 virCommandAbort(cmd); =20 if (kill(pid, 0) =3D=3D 0) { printf("Child should be aborted"); - goto cleanup; + return -1; } =20 alarm(0); =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 /* @@ -752,7 +728,6 @@ static int test20(const void *unused G_GNUC_UNUSED) g_autoptr(virCommand) cmd =3D virCommandNewArgList(abs_builddir "/comm= andhelper", "--close-stdin", NULL= ); g_autofree char *buf =3D NULL; - int ret =3D -1; =20 struct sigaction sig_action; =20 @@ -767,12 +742,10 @@ static int test20(const void *unused G_GNUC_UNUSED) =20 if (virCommandRun(cmd, NULL) < 0) { printf("Cannot run child %s\n", virGetLastErrorMessage()); - goto cleanup; + return -1; } =20 - ret =3D checkoutput("test20"); - cleanup: - return ret; + return checkoutput("test20"); } =20 static const char *const newenv[] =3D { @@ -790,7 +763,6 @@ static const char *const newenv[] =3D { static int test21(const void *unused G_GNUC_UNUSED) { g_autoptr(virCommand) cmd =3D virCommandNew(abs_builddir "/commandhelp= er"); - int ret =3D -1; const char *wrbuf =3D "Hello world\n"; g_autofree char *outbuf =3D NULL; g_autofree char *errbuf =3D NULL; @@ -808,28 +780,26 @@ static int test21(const void *unused G_GNUC_UNUSED) =20 if (virCommandRunAsync(cmd, NULL) < 0) { printf("Cannot run child %s\n", virGetLastErrorMessage()); - goto cleanup; + return -1; } =20 if (virCommandWait(cmd, NULL) < 0) - goto cleanup; + return -1; =20 if (virTestGetVerbose()) printf("STDOUT:%s\nSTDERR:%s\n", NULLSTR(outbuf), NULLSTR(errbuf)); =20 if (STRNEQ_NULLABLE(outbuf, outbufExpected)) { virTestDifference(stderr, outbufExpected, outbuf); - goto cleanup; + return -1; } =20 if (STRNEQ_NULLABLE(errbuf, errbufExpected)) { virTestDifference(stderr, errbufExpected, errbuf); - goto cleanup; + return -1; } =20 - ret =3D checkoutput("test21"); - cleanup: - return ret; + return checkoutput("test21"); } =20 static int @@ -1034,7 +1004,6 @@ static int test26(const void *unused G_GNUC_UNUSED) "bang \\\n" "wallop"; =20 - int ret =3D -1; VIR_AUTOCLOSE fd =3D -1; =20 virCommandAddEnvPair(cmd, "A", "B"); @@ -1046,28 +1015,25 @@ static int test26(const void *unused G_GNUC_UNUSED) =20 if ((outactual =3D virCommandToString(cmd, true)) =3D=3D NULL) { printf("Cannot convert to string: %s\n", virGetLastErrorMessage()); - goto cleanup; + return -1; } if ((fd =3D open(abs_builddir "/commandhelper.log", O_CREAT | O_TRUNC | O_WRONLY, 0600)) < 0) { printf("Cannot open log file: %s\n", g_strerror(errno)); - goto cleanup; + return -1; } virCommandWriteArgLog(cmd, fd); if (VIR_CLOSE(fd) < 0) { printf("Cannot close log file: %s\n", g_strerror(errno)); - goto cleanup; + return -1; } =20 if (STRNEQ(outactual, outexpect)) { virTestDifference(stderr, outexpect, outactual); - goto cleanup; + return -1; } =20 - ret =3D checkoutput("test26"); - - cleanup: - return ret; + return checkoutput("test26"); } =20 static int test27(const void *unused G_GNUC_UNUSED) --=20 2.26.2