From nobody Sat May 18 23:23:32 2024 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=1669801746; cv=none; d=zohomail.com; s=zohoarc; b=g9mA98RyPhl5SC3Nxb286RuDwOU6zXNdjSyuo+z7e4LrOfgdB9mMQ+Vj8ugqt8my52VtW4AlWOZbxyrudj9cP5madl3Q1SCliINgvcejAbEXPl1J3r9NzVofUS4XIbLC6GqBh2DjhLGfTT5F+QLmm/NbZgefO03Td5OpjYLbw08= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669801746; 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=07DnLIcYWa9Xpu4h+AvQsVYJdrIbPgBMMX1Jz2ca2lM=; b=dZALM0/b0YNbi1nN+tESzqbPbd6ejtT6mRfFDhDoaZ8J6ySDhZayInZiJ4tZl47yoJ2I0+FkyXOj+soRASiRA+QP7I0xDleXglwcjN1tToGewGD4ROflAKTaW1V37uVnLxKjHgW91Tg6d2h02MzzdMoWlMIZeBU9FtESKKYpMTY= 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 166980174657719.165815380806748; Wed, 30 Nov 2022 01:49:06 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-550-DaXjQp23ORmFi-m8QDDYYw-1; Wed, 30 Nov 2022 04:48:17 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2D34C1C08968; Wed, 30 Nov 2022 09:48:15 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD7042024CBE; Wed, 30 Nov 2022 09:48:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8976B19465A2; Wed, 30 Nov 2022 09:48:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CA69219465A0 for ; Wed, 30 Nov 2022 09:48:13 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B97694B3FCE; Wed, 30 Nov 2022 09:48:13 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E0434B3FC8 for ; Wed, 30 Nov 2022 09:48:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669801745; 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=07DnLIcYWa9Xpu4h+AvQsVYJdrIbPgBMMX1Jz2ca2lM=; b=Cz1N608cw2BvqORCWVOv1aMro9J0+A5kHy9Jux8odlnCgOzKkeWTTnoEPr5LvIG9oBKoYB G7WIHqpi3bgWC7sFstmK+MPsUk9EV/iFU+HI2l/LnC7FxpGds+OWIBxDUZphrhQ8EYXM13 teDF7QOlRMKK1LVALvJqR6dzqP64dew= X-MC-Unique: DaXjQp23ORmFi-m8QDDYYw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/9] vircommand: Document virCommandSetSendBuffer() behaviour wrt daemonize Date: Wed, 30 Nov 2022 10:48:03 +0100 Message-Id: <54a8c56168b2e6394ee443591e7d1717ce044d1f.1669801586.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1669801746952100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When virCommandSetSendBuffer() is used over a virCommand that is (or will be) daemonized, then the command must have VIR_EXEC_ASYNC_IO flag set no later than at virCommandRunAsync() phase so that the thread that's doing IO is spawned and thus buffers can be sent to the process. Signed-off-by: Michal Privoznik Reviewed-by: Jonathon Jongsma --- src/util/vircommand.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index bbfbe19706..cdc74bc2fd 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -1693,6 +1693,9 @@ virCommandFreeSendBuffers(virCommand *cmd) * @buffer is always stolen regardless of the return value. This function * doesn't raise a libvirt error, but rather propagates the error via virC= ommand. * Thus callers don't need to take a special action if -1 is returned. + * + * When the @cmd is daemonized via virCommandDaemonize() remember to reque= st + * asynchronous IO via virCommandDoAsyncIO(). */ int virCommandSetSendBuffer(virCommand *cmd, --=20 2.37.4 From nobody Sat May 18 23:23:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1669801705; cv=none; d=zohomail.com; s=zohoarc; b=dFJcjmmV26sm5o4kIVjAPytjhGeyWS7Gw+yJisaNQSRrrSFFe54T+jhZOp3dd4Vk2trq+N+WaUihFBzUz7ISXIuGrS8H2dCfO5lXTF574Wdl/vyFPpuYGpUiaFlc+sU7atx//dczY5h7+pUH49t5qmq7pz4R+c989kSF5FxWyAw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669801705; 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=tSB9Tw74tV4TZ9kuztq5SDUalPaYXQb3Tk9csnJedu4=; b=nc83yUTHyahGPp3cgqo1eeNbTtJQm7Gcxw/sr6Y8U8MNLqLx0514dWtUPQtFHcnK7be3FjwpRfdb0PFHpyokDlvXnrXZztcl2navmlJFJudlDsUDpXAOR8CHRKf60tQ+czpM8JMYsVFKAooSAER0F8racDARSuR2TbR0oq8QAvE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1669801705587844.4975939480919; Wed, 30 Nov 2022 01:48:25 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-604-hGzPRJf5MJSrcehXPksYWg-1; Wed, 30 Nov 2022 04:48:22 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1C7F31C08980; Wed, 30 Nov 2022 09:48:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07662492B15; Wed, 30 Nov 2022 09:48:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id F088319465A8; Wed, 30 Nov 2022 09:48:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7445519465A0 for ; Wed, 30 Nov 2022 09:48:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 588EA4B3FCE; Wed, 30 Nov 2022 09:48:14 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id F1ACA4B3FC8 for ; Wed, 30 Nov 2022 09:48:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669801704; 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=tSB9Tw74tV4TZ9kuztq5SDUalPaYXQb3Tk9csnJedu4=; b=feMEDYZArXGMv75ewb/1cU19bDM/2C0ELq4jO9rDbJCTI8UIfgC+IoBbKsYVHjK7sfV0Dc v4E0j8Z6gr9Tnsl5Jt2vgZu0zxYGXwoGIvlb8uHfjX62bgFQLu2z5L1/0ugLTkr9LURZ3Z Y9sHzs0R0mVBHRDBgrOnjH822KdcmkE= X-MC-Unique: hGzPRJf5MJSrcehXPksYWg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/9] virCommandDoAsyncIO: Drop misleading statement about main event loop Date: Wed, 30 Nov 2022 10:48:04 +0100 Message-Id: <5764adf6a751f8c1fad8c9b2a9592a53e2039939.1669801586.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: 1669801706757100003 Content-Type: text/plain; charset="utf-8"; x-default="true" Back in v1.0.3-rc1~235 when I was adding virCommandDoAsyncIO(), the main event loop was used to poll() on the pipe to the child process. But this was promptly changed to a separate thread handling I/O in v1.0.3-rc1~127. However, the corresponding comment to virCommandDoAsyncIO() still documents the original state. Signed-off-by: Michal Privoznik Reviewed-by: Jonathon Jongsma --- src/util/vircommand.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index cdc74bc2fd..4f60432c0a 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -3078,8 +3078,6 @@ virCommandFree(virCommand *cmd) * * ... * - * - * The libvirt's event loop is used for handling stdios of @cmd. * Since current implementation uses strlen to determine length * of data to be written to @cmd's stdin, don't pass any binary * data. If you want to re-run command, you need to call this and --=20 2.37.4 From nobody Sat May 18 23:23:32 2024 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=1669801704; cv=none; d=zohomail.com; s=zohoarc; b=CqyrtEfir0M7f2pfKZyfl4hhLKAT83OfzWs86GDRslSXAcMEFGSCopKq2BDOp6PPqDZ1GuADKqi60dRyS1kGVsvruXo7JDiTL5c+GnpJE79tHXwJ0O+oemYeCcyzsKMF84EKo77fm4KURTQQCVGbI4l5x+wJkYUYdoqzkdjZd2Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669801704; 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=K5v5tHwsUWW5fgfGCiyBD7HBLtUwCzVNqD+6poA0W9Q=; b=MyK65HWiDzEC0zWI//4uXZ/G0CkZL+mGOpzCQ/fIgaSofbhz8TiAUmSxx9GUsw5z5pT9JwChtLEDEYr3pKMuzzNazozEhLpC6tz5zoYvSXytyCHowaGDs9jcsg9IbNbdad69nOOcckHf9hCOqh+hrX2cJvNvMt4hhd7EB0G+2lI= 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 1669801704033453.4692096800113; Wed, 30 Nov 2022 01:48:24 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-523-pLnbTvMVO-CdwjyZKvsHGQ-1; Wed, 30 Nov 2022 04:48:20 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 27D2B3810797; Wed, 30 Nov 2022 09:48:17 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED64DC15BA4; Wed, 30 Nov 2022 09:48:16 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DF81E19465A4; Wed, 30 Nov 2022 09:48:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 178B919465A0 for ; Wed, 30 Nov 2022 09:48:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EE1984B3FCE; Wed, 30 Nov 2022 09:48:14 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 921F24B3FC8 for ; Wed, 30 Nov 2022 09:48:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669801703; 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=K5v5tHwsUWW5fgfGCiyBD7HBLtUwCzVNqD+6poA0W9Q=; b=h/NtlzD3fGbemXoRPgr8Se2W28ETrTIQnHdo9wChkWbH+Osfs/AQ3KvJou6BZBIwuEMn1j MGvCIRzXoYvw32p4bUXFu1BgPMqK6PV/4wqy7LjVID+fN4oibPz3LqJwQthKBHKt1hEBS1 CLrFw+Pm5bAMcjqtsw+Yh769yBAz4aA= X-MC-Unique: pLnbTvMVO-CdwjyZKvsHGQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/9] commandtest: Use unsigned char in test27() Date: Wed, 30 Nov 2022 10:48:05 +0100 Message-Id: <2f632ea24b51afc093289f8986412a5921710b86.1669801586.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: 1669801704756100001 Content-Type: text/plain; charset="utf-8"; x-default="true" In test27() the virCommandSetSendBuffer() is used, which expects unsigned char. Use that type for variables which are passed to the function. Signed-off-by: Michal Privoznik Reviewed-by: Jonathon Jongsma --- tests/commandtest.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/commandtest.c b/tests/commandtest.c index 95d1bfa91b..9bbf6fb260 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -1041,8 +1041,8 @@ static int test27(const void *unused G_GNUC_UNUSED) int buf2fd; size_t buflen =3D 1024 * 128; g_autofree char *buffer0 =3D NULL; - g_autofree char *buffer1 =3D NULL; - g_autofree char *buffer2 =3D NULL; + g_autofree unsigned char *buffer1 =3D NULL; + g_autofree unsigned char *buffer2 =3D NULL; g_autofree char *outactual =3D NULL; g_autofree char *erractual =3D NULL; g_autofree char *outexpect =3D NULL; @@ -1055,8 +1055,8 @@ static int test27(const void *unused G_GNUC_UNUSED) "END STDERR\n" =20 buffer0 =3D g_new0(char, buflen); - buffer1 =3D g_new0(char, buflen); - buffer2 =3D g_new0(char, buflen); + buffer1 =3D g_new0(unsigned char, buflen); + buffer2 =3D g_new0(unsigned char, buflen); =20 memset(buffer0, 'H', buflen - 2); buffer0[buflen - 2] =3D '\n'; @@ -1075,8 +1075,8 @@ static int test27(const void *unused G_GNUC_UNUSED) errexpect =3D g_strdup_printf(TEST27_ERREXPECT_TEMP, buffer0, buffer1, buffer2); =20 - buf1fd =3D virCommandSetSendBuffer(cmd, (unsigned char *) g_steal_poin= ter(&buffer1), buflen - 1); - buf2fd =3D virCommandSetSendBuffer(cmd, (unsigned char *) g_steal_poin= ter(&buffer2), buflen - 1); + buf1fd =3D virCommandSetSendBuffer(cmd, g_steal_pointer(&buffer1), buf= len - 1); + buf2fd =3D virCommandSetSendBuffer(cmd, g_steal_pointer(&buffer2), buf= len - 1); =20 virCommandAddArg(cmd, "--readfd"); virCommandAddArgFormat(cmd, "%d", buf1fd); --=20 2.37.4 From nobody Sat May 18 23:23:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1669801709; cv=none; d=zohomail.com; s=zohoarc; b=cYz5zB7WPUcn+wcl4ZZzlSQx9tlBT4gUpyjMsAg1VN4XdFOdcSMNbNJqQJErI1UF43dGUxRxeC5z9bbxUQ3RlG5yluUpWPt+tISHx8oTa+Ead612riPM+97TVwQmKRAirmqfYydm58+smqNzzS9jFWbQSmu193gTHOjghINKz3Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669801709; 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=ftsd3DV/PBgZx386dcZuEd+MZAy9kJ4MiBhfmEKMpsM=; b=cr9Mlh1+G8txvBfopppEqxD1T9xAUTz8+7Q+AZaB4QHSgalDo3nIJKryFkpaBYL6m30kL7vBv58V52XVZwWC/ZGDbTn0rVtyBDS7B0ixqr9YkRAdoJ3W1qxBB/UwU657sEu4B9tOW0robeAsa2tuyIkGSH+NtqcBy9vs2YDWdvg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1669801709197746.6169743427728; Wed, 30 Nov 2022 01:48:29 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-472-853G6YN4PbiwZ4DyPCsRuw-1; Wed, 30 Nov 2022 04:48:24 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 891991C008AB; Wed, 30 Nov 2022 09:48:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74EBC2166B2D; Wed, 30 Nov 2022 09:48:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6541219465A8; Wed, 30 Nov 2022 09:48:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9A5C019465A0 for ; Wed, 30 Nov 2022 09:48:15 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8E7CE4B3FCE; Wed, 30 Nov 2022 09:48:15 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3249A4B3FDF for ; Wed, 30 Nov 2022 09:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669801707; 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=ftsd3DV/PBgZx386dcZuEd+MZAy9kJ4MiBhfmEKMpsM=; b=AiVezKYfl08rAOyFCpA0Ek3ARH+QFDCNBqN4AsdQqmOVDSZ3ilt551RjKKPz1EELg2J9TE 0EEDdavyCYiObZUmb6dHMTtR0pqiuKIcTu6kJk7KG4kAVBOPQy+SZqvs6wKT9EC2qml/dQ WBgI2f8C6vJUEf862oxQBPK3p8RjiZQ= X-MC-Unique: 853G6YN4PbiwZ4DyPCsRuw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/9] virCommandSetSendBuffer: Take double pointer of @buffer Date: Wed, 30 Nov 2022 10:48:06 +0100 Message-Id: <06993770963a937e0f15e7232bb3f39363847ad7.1669801586.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: 1669801710797100004 Content-Type: text/plain; charset="utf-8"; x-default="true" The virCommandSetSendBuffer() function consumes passed @buffer, but takes it only as plain pointer. Switch to a double pointer to make this obvious. This allows us then to drop all g_steal_pointer() in callers. Signed-off-by: Michal Privoznik Reviewed-by: Jonathon Jongsma --- src/qemu/qemu_tpm.c | 2 +- src/util/vircommand.c | 6 +++--- src/util/vircommand.h | 2 +- tests/commandtest.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index bdce060db8..d2f5bfb055 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -265,7 +265,7 @@ qemuTPMSetupEncryption(const unsigned char *secretuuid, &secret, &secret_len) < 0) return -1; =20 - *fd =3D virCommandSetSendBuffer(cmd, g_steal_pointer(&secret), secret_= len); + *fd =3D virCommandSetSendBuffer(cmd, &secret, secret_len); return 0; } =20 diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 4f60432c0a..0917bc9cfb 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -1699,10 +1699,10 @@ virCommandFreeSendBuffers(virCommand *cmd) */ int virCommandSetSendBuffer(virCommand *cmd, - unsigned char *buffer, + unsigned char **buffer, size_t buflen) { - g_autofree unsigned char *localbuf =3D g_steal_pointer(&buffer); + g_autofree unsigned char *localbuf =3D g_steal_pointer(buffer); int pipefd[2] =3D { -1, -1 }; size_t i; =20 @@ -2901,7 +2901,7 @@ int virCommandHandshakeNotify(virCommand *cmd) #else /* WIN32 */ int virCommandSetSendBuffer(virCommand *cmd, - unsigned char *buffer G_GNUC_UNUSED, + unsigned char **buffer G_GNUC_UNUSED, size_t buflen G_GNUC_UNUSED) { if (virCommandHasError(cmd)) diff --git a/src/util/vircommand.h b/src/util/vircommand.h index 98788bcbf7..e0002103b6 100644 --- a/src/util/vircommand.h +++ b/src/util/vircommand.h @@ -132,7 +132,7 @@ void virCommandSetWorkingDirectory(virCommand *cmd, const char *pwd) ATTRIBUTE_NONNULL(2); =20 int virCommandSetSendBuffer(virCommand *cmd, - unsigned char *buffer, + unsigned char **buffer, size_t buflen) ATTRIBUTE_NONNULL(2); =20 diff --git a/tests/commandtest.c b/tests/commandtest.c index 9bbf6fb260..8c5a9245a1 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -1075,8 +1075,8 @@ static int test27(const void *unused G_GNUC_UNUSED) errexpect =3D g_strdup_printf(TEST27_ERREXPECT_TEMP, buffer0, buffer1, buffer2); =20 - buf1fd =3D virCommandSetSendBuffer(cmd, g_steal_pointer(&buffer1), buf= len - 1); - buf2fd =3D virCommandSetSendBuffer(cmd, g_steal_pointer(&buffer2), buf= len - 1); + buf1fd =3D virCommandSetSendBuffer(cmd, &buffer1, buflen - 1); + buf2fd =3D virCommandSetSendBuffer(cmd, &buffer2, buflen - 1); =20 virCommandAddArg(cmd, "--readfd"); virCommandAddArgFormat(cmd, "%d", buf1fd); --=20 2.37.4 From nobody Sat May 18 23:23:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1669801710; cv=none; d=zohomail.com; s=zohoarc; b=DWSIIWTYDC/UTieg9ShJtEnn5s1Zll8cJ0VsbFAfdqP7ZoxtyXl9FLOLoMkJ2OyVtaun3zNJOkPG3sIHasqmiJUyCK92eE5Z+W1c8U1KzPHuCF2n8H3F6tyNiTkwjYSVg+s6+iNjIz0ROvUthndTYBcXg9kdV/J7y4Z56J8uOZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669801710; 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=jIMjpJshCdyxIPTReIsxydCqH83QcRdVi7ULA7aVpTo=; b=ZiUa4R1lYhrFWiIA1UwX9mYYwA2wUo/MYkjWJ2Apc6MRwRS1QyKxKhp9LCtOmGfecKN6IAFaMghOJLNyvHMf3Xm4SheWYmT/q+ORZBw0W25j0QhR52PWo+iqPecIzvz5Znw0tAVd+y8cLFNIf2RNqvZivvWyJ1/h9ykINQzESK4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1669801710376121.87369199928378; Wed, 30 Nov 2022 01:48:30 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-580-X9t4_p4ANKqKof65VNqFQw-1; Wed, 30 Nov 2022 04:48:21 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 52DFD381079B; Wed, 30 Nov 2022 09:48:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F55D4B3FCE; Wed, 30 Nov 2022 09:48:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2D41F19465A2; Wed, 30 Nov 2022 09:48:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3D5BE19465A0 for ; Wed, 30 Nov 2022 09:48:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2F6324B3FC8; Wed, 30 Nov 2022 09:48:16 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7D134B3FDF for ; Wed, 30 Nov 2022 09:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669801709; 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=jIMjpJshCdyxIPTReIsxydCqH83QcRdVi7ULA7aVpTo=; b=gL2teZLXrf7gQzjBLQT8pWj5rZm3G/0X68GYw0CbG5QBQaXfSqckBhQRNzhy0HEuvHrvwq nQGEuibTtsehKDry/PDXB3Atq3H53G7jAWSmcKkvwvrhgOb51PqH4VB/yHuKVvK24tEO43 mv1oP14kTLfYj72XBLU0wxt9cUAm97o= X-MC-Unique: X9t4_p4ANKqKof65VNqFQw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 5/9] commandtest: Test virCommandSetSendBuffer() with virCommandDoAsyncIO() Date: Wed, 30 Nov 2022 10:48:07 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: 1669801710797100003 Content-Type: text/plain; charset="utf-8"; x-default="true" Introduce a test case which ensures that a daemonized process can work with virCommandSetSendBuffer() when async IO is enabled. Signed-off-by: Michal Privoznik Reviewed-by: Jonathon Jongsma --- tests/commanddata/test29.log | 20 ++++++++ tests/commandtest.c | 97 ++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 tests/commanddata/test29.log diff --git a/tests/commanddata/test29.log b/tests/commanddata/test29.log new file mode 100644 index 0000000000..962f8526f1 --- /dev/null +++ b/tests/commanddata/test29.log @@ -0,0 +1,20 @@ +ARG:--close-stdin +ARG:--check-daemonize +ARG:--readfd +ARG:3 +ENV:DISPLAY=3D:0.0 +ENV:HOME=3D/home/test +ENV:HOSTNAME=3Dtest +ENV:LANG=3DC +ENV:LOGNAME=3Dtest +ENV:PATH=3D/usr/bin:/bin +ENV:TMPDIR=3D/tmp +ENV:USER=3Dtest +FD:0 +FD:1 +FD:2 +FD:3 +FD:6 +DAEMON:yes +CWD:/ +UMASK:0022 diff --git a/tests/commandtest.c b/tests/commandtest.c index 8c5a9245a1..6d45ff196f 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -25,6 +25,7 @@ #include #ifndef WIN32 # include +# include #endif #include =20 @@ -1155,6 +1156,101 @@ test28(const void *unused G_GNUC_UNUSED) } =20 =20 +static int +test29(const void *unused G_GNUC_UNUSED) +{ + g_autoptr(virCommand) cmd =3D virCommandNew(abs_builddir "/commandhelp= er"); + g_autofree char *pidfile =3D virPidFileBuildPath(abs_builddir, "comman= dhelper"); + pid_t pid; + int buffd; + VIR_AUTOCLOSE outfd =3D -1; + size_t buflen =3D 1024 * 10; + g_autofree unsigned char *buffer =3D NULL; + g_autofree char *outactual =3D NULL; + g_autofree char *outexpect =3D NULL; + size_t i; + size_t outactuallen =3D 0; + int ret =3D -1; + + if (!pidfile) + return -1; + + buffer =3D g_new0(unsigned char, buflen + 1); + for (i =3D 0; i < buflen; i++) { + buffer[i] =3D 'a' + i % ('z' - 'a' + 1); + } + buffer[buflen] =3D '\0'; + + outexpect =3D g_strdup_printf("BEGIN STDOUT\n%sEND STDOUT\n", buffer); + + buffd =3D virCommandSetSendBuffer(cmd, &buffer, buflen); + + virCommandAddArg(cmd, "--close-stdin"); + virCommandAddArg(cmd, "--check-daemonize"); + virCommandAddArg(cmd, "--readfd"); + virCommandAddArgFormat(cmd, "%d", buffd); + + virCommandSetOutputFD(cmd, &outfd); + virCommandSetPidFile(cmd, pidfile); + virCommandDaemonize(cmd); + virCommandDoAsyncIO(cmd); + + if (virCommandRun(cmd, NULL) < 0) { + fprintf(stderr, "Cannot run child %s\n", virGetLastErrorMessage()); + goto cleanup; + } + + if (virPidFileReadPath(pidfile, &pid) < 0) { + fprintf(stderr, "cannot read pidfile: %s\n", pidfile); + goto cleanup; + } + + while (1) { + char buf[1024] =3D { 0 }; + struct pollfd pfd =3D {.fd =3D outfd, .events =3D POLLIN, .revents= =3D 0}; + int rc =3D 0; + + rc =3D poll(&pfd, 1, 1000); + if (rc < 0) { + if (errno =3D=3D EINTR) + continue; + + fprintf(stderr, "poll() returned errno =3D %d\n", errno); + goto cleanup; + } + + if (pfd.revents & POLLIN) { + rc =3D read(outfd, buf, sizeof(buf)); + if (rc < 0) { + fprintf(stderr, "cannot read from output pipe: errno=3D%d\= n", errno); + goto cleanup; + } + + outactual =3D g_renew(char, outactual, outactuallen + rc + 1); + memcpy(outactual + outactuallen, buf, rc); + outactuallen +=3D rc; + outactual[outactuallen] =3D '\0'; + } else if (pfd.revents & POLLERR || + pfd.revents & POLLHUP) { + break; + } + } + + if (STRNEQ_NULLABLE(outactual, outexpect)) { + virTestDifference(stderr, outexpect, outactual); + goto cleanup; + } + + ret =3D checkoutput("test29"); + + cleanup: + if (pidfile) + unlink(pidfile); + + return ret; +} + + static int mymain(void) { @@ -1252,6 +1348,7 @@ mymain(void) DO_TEST(test26); DO_TEST(test27); DO_TEST(test28); + DO_TEST(test29); =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } --=20 2.37.4 From nobody Sat May 18 23:23:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1669801712; cv=none; d=zohomail.com; s=zohoarc; b=jF5o9nUGkIj91lP2/oDR+OrTuQqhzCVIKaChbjF8exGi4VcILNDIpd5EUPAA/pIMD0OHr6i1x95SgKS+tmT1oIMKV21+o4gmfSHixEmV2EV5GoU/jqr+91okjrDN4c6S3Qp00KLNQDhLeR5G/W05IygLrB0T+/LZns7tUAwXISU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669801712; 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=yNXSrwuULZodtSjaJuqJ6rHa6EvZU7VqM7y8OpqeQcw=; b=lNN2HesZ8SlX/AVNm13iO763IzIjWfyrxj8jg36Ve/S2VHjMhJBVOl31y+ivymGXP0uFaQh+fHzX7GlExPH0zGRum9daNHG5dN1HKTYOSqe2J67j9/s6hXwb5tqHroaoUbUZ4qxE3NO01FsfWMO/LC82qf1R+vbhRF+DqbU+mzQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1669801712416139.17281621149925; Wed, 30 Nov 2022 01:48:32 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-314-ui1wV_jrMRKdDPOWDaKr1g-1; Wed, 30 Nov 2022 04:48:22 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F34933C0DDB8; Wed, 30 Nov 2022 09:48:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD4584B3FCE; Wed, 30 Nov 2022 09:48:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D1D8819465A0; Wed, 30 Nov 2022 09:48:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CEFA219465A0 for ; Wed, 30 Nov 2022 09:48:16 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C23264B3FCE; Wed, 30 Nov 2022 09:48:16 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 679DA4B3FC8 for ; Wed, 30 Nov 2022 09:48:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669801711; 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=yNXSrwuULZodtSjaJuqJ6rHa6EvZU7VqM7y8OpqeQcw=; b=buHowGmDuWY6GXSfmNG77nmfZzRv31oQNVn8r+FC41TOC+qrMuoD1/S5PZxxa8mulWDiQS csX/FHrZ6RezUeg4aIFkklNqoSzM7aO6HgBHoS3+OgZCuCzyDOBKm9dpyAurlPziv+tT95 57NBCp+msAG4FBcM+0+HXh4jV61OIUY= X-MC-Unique: ui1wV_jrMRKdDPOWDaKr1g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 6/9] commandtest: Use virTestCompareToFile() in checkoutput() Date: Wed, 30 Nov 2022 10:48:08 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: 1669801712807100007 Content-Type: text/plain; charset="utf-8"; x-default="true" In the commandtest there is checkoutput() function which checks the latest log of commandhelper (containing things like cmd line arguments, env vars, FDs, CWD, etc.) and compares that against expected output. Well, the way this function implements that is effectively by open coding virTestCompareToFile() except for the nice feature that the virTestCompareToFile() has: VIR_TEST_OUTPUT_REGENERATE. Signed-off-by: Michal Privoznik Reviewed-by: Jonathon Jongsma --- tests/commandtest.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/tests/commandtest.c b/tests/commandtest.c index 6d45ff196f..ffc4b24ef4 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -58,29 +58,18 @@ static int checkoutput(const char *testname) { int ret =3D -1; g_autofree char *expectname =3D NULL; - g_autofree char *expectlog =3D NULL; g_autofree char *actualname =3D NULL; g_autofree char *actuallog =3D NULL; =20 expectname =3D g_strdup_printf("%s/commanddata/%s.log", abs_srcdir, te= stname); actualname =3D g_strdup_printf("%s/commandhelper.log", abs_builddir); =20 - if (virFileReadAll(expectname, 1024*64, &expectlog) < 0) { - fprintf(stderr, "cannot read %s\n", expectname); - goto cleanup; - } - if (virFileReadAll(actualname, 1024*64, &actuallog) < 0) { fprintf(stderr, "cannot read %s\n", actualname); goto cleanup; } =20 - if (STRNEQ(expectlog, actuallog)) { - virTestDifference(stderr, expectlog, actuallog); - goto cleanup; - } - - ret =3D 0; + ret =3D virTestCompareToFile(actuallog, expectname); =20 cleanup: if (actualname) @@ -1292,6 +1281,7 @@ mymain(void) * since we're about to reset 'environ' */ ignore_value(virTestGetDebug()); ignore_value(virTestGetVerbose()); + ignore_value(virTestGetRegenerate()); =20 /* Make sure to not leak fd's */ virinitret =3D virInitialize(); --=20 2.37.4 From nobody Sat May 18 23:23:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1669801707; cv=none; d=zohomail.com; s=zohoarc; b=Me6/L0EVaCXi8ITGfcCNBzcl6eqinrkcPZq/XkLjlVZ9rKs0YYRZysuSgJJGrIxDJCS3gUALtOtBPi/LX2I1hKk4MNs5KWY7utHr+qd9+ali8UF/dpnuHBFrnzc7jBAf95IU2Fr8Dz1/NC72NyKitEPvhroSZoGsJbT7fsEOaPk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669801707; 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=ji0+22//VXmoEwPZ9292IPYBWPVzr+pR09lp4x5HKUI=; b=Hc3z3MVSC/cMXiODuJgPNdkqsi+PdHc1DM26FZk3My1WSqqv88IHzhe56VCnDBfXc1DY6KJGZ5WBowykxZmS64Iox4ntBn8ThqQAw6rBpxxx85QL2iHjD+GTBsUVe/HK/JEx1w9ku2xIucXYYExzQVxtkPvWiFOqlsAKDRJ7b3w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1669801707415497.50585386573016; Wed, 30 Nov 2022 01:48:27 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-108-zfTjJX3QO-22ab7WHYrDxQ-1; Wed, 30 Nov 2022 04:48:22 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D523529DD994; Wed, 30 Nov 2022 09:48:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B79561401C2D; Wed, 30 Nov 2022 09:48:18 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7FD771946A40; Wed, 30 Nov 2022 09:48:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6FC9219465A0 for ; Wed, 30 Nov 2022 09:48:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 63ABE4B3FCE; Wed, 30 Nov 2022 09:48:17 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 081FB4B3FC8 for ; Wed, 30 Nov 2022 09:48:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669801705; 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=ji0+22//VXmoEwPZ9292IPYBWPVzr+pR09lp4x5HKUI=; b=VupwzaWOiGtN4wwxdePn5LSgXUIlzXQJJSd7G4IrxoEe4kszSiSW/i3WaRxe1Do60nfUz7 AEv906iDXEBPa2TvvQOAD4ySzBE5JfR7xMkRKh7uAxSTquRKKnPDunW57YVL0P8+vDYUoV Z7U6d8KTuSgGu3lllVOCT//a0M8JlMw= X-MC-Unique: zfTjJX3QO-22ab7WHYrDxQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 7/9] virbuftest: Cleanup code around virTestDifference() Date: Wed, 30 Nov 2022 10:48:09 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: 1669801708791100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Two things are happening here: 1) Call to virTestDifference() is guarded by '!result || STRNEQ(result, _)' check. This is suboptimal since we have STRNEQ_NULLABLE(). 2) There are couple of VIR_TEST_DEBUG() printings, which are useless. If debug is off they don't print anything, and if it is on, then much more information is printed by subsequent virTestDifference(). This makes the STRNEQ() + virTestDifference() combo look similar to the rest of tests and thus can be picked up by spatch later. Signed-off-by: Michal Privoznik Reviewed-by: Jonathon Jongsma --- tests/virbuftest.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/virbuftest.c b/tests/virbuftest.c index 0ca7927c3f..144df6e66b 100644 --- a/tests/virbuftest.c +++ b/tests/virbuftest.c @@ -92,7 +92,7 @@ static int testBufAutoIndent(const void *data G_GNUC_UNUS= ED) virBufferAddChar(buf, '\n'); =20 result =3D virBufferContentAndReset(buf); - if (!result || STRNEQ(result, expected)) { + if (STRNEQ_NULLABLE(result, expected)) { virTestDifference(stderr, expected, result); ret =3D -1; } @@ -122,7 +122,7 @@ static int testBufTrim(const void *data G_GNUC_UNUSED) virBufferTrim(buf, ",,"); =20 result =3D virBufferContentAndReset(buf); - if (!result || STRNEQ(result, expected)) { + if (STRNEQ_NULLABLE(result, expected)) { virTestDifference(stderr, expected, result); return -1; } @@ -146,7 +146,6 @@ testBufTrimChars(const void *opaque) } =20 if (STRNEQ_NULLABLE(actual, data->expect)) { - VIR_TEST_DEBUG("testBufEscapeStr(): Strings don't match:"); virTestDifference(stderr, data->expect, actual); return -1; } @@ -278,7 +277,6 @@ testBufAddStr(const void *opaque) } =20 if (STRNEQ_NULLABLE(actual, data->expect)) { - VIR_TEST_DEBUG("testBufAddStr(): Strings don't match:"); virTestDifference(stderr, data->expect, actual); return -1; } @@ -306,7 +304,6 @@ testBufEscapeStr(const void *opaque) } =20 if (STRNEQ_NULLABLE(actual, data->expect)) { - VIR_TEST_DEBUG("testBufEscapeStr(): Strings don't match:"); virTestDifference(stderr, data->expect, actual); return -1; } @@ -330,7 +327,6 @@ testBufEscapeRegex(const void *opaque) } =20 if (STRNEQ_NULLABLE(actual, data->expect)) { - VIR_TEST_DEBUG("testBufEscapeRegex: Strings don't match:"); virTestDifference(stderr, data->expect, actual); return -1; } --=20 2.37.4 From nobody Sat May 18 23:23:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1669801747; cv=none; d=zohomail.com; s=zohoarc; b=jKZ6esffzt3hrflSCrqcGn03yzSPxB4RvO6vqmCM3uLARmXNJq5fGh94ZXzEgL2aPYl66FmiSLFBELIeIXqitkgtQ/gMnBXC1mEwa+ypROa+B8j20F9llEuEIwUv9UUdDgtp5gRNt1CkCVmy+Q1jVljp83uZRx5RoZVFaMl8t/o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669801747; 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=JUPmsuIc1AGga4qDpVMmGVKD09MiwDrkKVPIIdVKfnk=; b=jEEEiWc49u5UOVqmrIce2NRcX7UMAKOVXLpvCk+BxUAF0WYksAnTf2ufFNEQjVsJVxzYm13LPZW+FmZIb9+IOifJVy5SLhujmtdMQB2U2uIJ/2qEV32KAra2xmy8pBM/rLVAo1IoDVr4hOYUjzYSZcnGemV2akur13MRilrRquY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1669801747725616.8222924659625; Wed, 30 Nov 2022 01:49:07 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-500-j6KwV6b0OC-OftoYpyIYzQ-1; Wed, 30 Nov 2022 04:48:23 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 44DE829324A9; Wed, 30 Nov 2022 09:48:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C591111E3FF; Wed, 30 Nov 2022 09:48:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 204AD1946A40; Wed, 30 Nov 2022 09:48:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2EDBB19465A4 for ; Wed, 30 Nov 2022 09:48:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 03D4A4B3FCE; Wed, 30 Nov 2022 09:48:18 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C48D4B3FC8 for ; Wed, 30 Nov 2022 09:48:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669801746; 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=JUPmsuIc1AGga4qDpVMmGVKD09MiwDrkKVPIIdVKfnk=; b=ZfuCBQV5zoGDeNGWh6wZ7bFwfUVpzZuJAfepG5wTZMXd//roK7L5CLErme9sWYMX9jJxLb 5EYkqj8o7hO03E0kE2cjtAIqBbGHtMaifmDsxubjh5K+js5UgIfI1O/Qx6/NdZykBBjbu3 NFfK0Wj2MB8gcd5mwEuUikBc96bKahs= X-MC-Unique: j6KwV6b0OC-OftoYpyIYzQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 8/9] tests: Don't wrap virTestDifference() arguments in NULLSTR() Date: Wed, 30 Nov 2022 10:48:10 +0100 Message-Id: <5c278b6e2922e47eddbe7de90122117c71bf5f48.1669801586.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: 1669801748960100005 Content-Type: text/plain; charset="utf-8"; x-default="true" The virTestDifference() is perfectly capable of handling NULL arguments. There's no need to wrap arguments in NULLSTR(). Signed-off-by: Michal Privoznik Reviewed-by: Jonathon Jongsma --- tests/virnetdevbandwidthtest.c | 4 +--- tests/virnetdevopenvswitchtest.c | 8 ++------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/tests/virnetdevbandwidthtest.c b/tests/virnetdevbandwidthtest.c index d5e4092fc3..fced657811 100644 --- a/tests/virnetdevbandwidthtest.c +++ b/tests/virnetdevbandwidthtest.c @@ -93,9 +93,7 @@ testVirNetDevBandwidthSet(const void *data) } =20 if (STRNEQ_NULLABLE(exp_cmd, actual_cmd)) { - virTestDifference(stderr, - NULLSTR(exp_cmd), - NULLSTR(actual_cmd)); + virTestDifference(stderr, exp_cmd, actual_cmd); return -1; } =20 diff --git a/tests/virnetdevopenvswitchtest.c b/tests/virnetdevopenvswitcht= est.c index 57860f4bc4..e5883eb076 100644 --- a/tests/virnetdevopenvswitchtest.c +++ b/tests/virnetdevopenvswitchtest.c @@ -176,9 +176,7 @@ testVirNetDevOpenvswitchInterfaceSetQos(const void *dat= a) } =20 if (STRNEQ_NULLABLE(info->exp_cmd, actual_cmd)) { - virTestDifference(stderr, - NULLSTR(info->exp_cmd), - NULLSTR(actual_cmd)); + virTestDifference(stderr, info->exp_cmd, actual_cmd); return -1; } =20 @@ -207,9 +205,7 @@ testVirNetDevOpenvswitchInterfaceClearQos(const void *d= ata) } =20 if (STRNEQ_NULLABLE(info->exp_cmd, actual_cmd)) { - virTestDifference(stderr, - NULLSTR(info->exp_cmd), - NULLSTR(actual_cmd)); + virTestDifference(stderr, info->exp_cmd, actual_cmd); return -1; } =20 --=20 2.37.4 From nobody Sat May 18 23:23:32 2024 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=1669801753; cv=none; d=zohomail.com; s=zohoarc; b=RIA/hs+3z42E0jsqS/1TDGGBHolmvvmVgBrzNelwU0Gby7WGJjF2Ifjdr9PutX0Yqeb3VQZIXRil8RqmjG7ILmR0mX5/vycAVMN7XoolFI32qyGcNTgFnXWYPAwCGsanTgdYzNW6YiyejWhxQA0L2MXv8IpHpZ8gXYglRAcj63E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669801753; 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=68MEr925cjHMi5a/rNsMGOYwGlWQBEC9N0y0h/OtHSI=; b=J2BJPFYz6RWNkapMq833QT8AnMccEjLN4K7TdQOyr+faZuy8QXTb+5lXcbvH/58zYkOoOjj9JjpvVvAqntMQZ4CHKO80XnabCK8lt1D0iZNZPt7g9srOSq3cQhj9u8fs/6ayRegKr13LRXyAOZn12t05Q0T6q3AzpF9aTMdJH1U= 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 1669801753821638.1092010167605; Wed, 30 Nov 2022 01:49:13 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-619-i6N4U8mXPfWchbFenOI2HA-1; Wed, 30 Nov 2022 04:48:23 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 787B0832D60; Wed, 30 Nov 2022 09:48:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 586581401C25; Wed, 30 Nov 2022 09:48:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4C1CD19465BA; Wed, 30 Nov 2022 09:48:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C14CA19465B2 for ; Wed, 30 Nov 2022 09:48:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B47A44B3FE5; Wed, 30 Nov 2022 09:48:18 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C7284B3FC8 for ; Wed, 30 Nov 2022 09:48:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669801752; 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=68MEr925cjHMi5a/rNsMGOYwGlWQBEC9N0y0h/OtHSI=; b=dRiw/KJqm7pVKsBZAAVxAyRQ1yw8tTBkHe+0HFXg0BeZ0fsi4aNfXEsbMlWUobz0Kkfuqc UmV940hA0cpqI9LmrcY8eupPqCvXCLA1Q1RslIaDlW/To50l5n7Ab/yJW3aXuKIQD7YPm4 LYNMWMJ10RTUR7RTW5szerZcqfL3+RM= X-MC-Unique: i6N4U8mXPfWchbFenOI2HA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 9/9] tests: Use virTestCompareToString() more Date: Wed, 30 Nov 2022 10:48:11 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: 1669801755044100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Instead of using: if (STRNEQ(a, b)) { virTestDifference(stderr, a, b); ... } we can use: if (virTestCompareToString(a, b) < ) { ... } Generated by the following spatch: @@ expression a, b; @@ - if (STRNEQ(a, b)) { + if (virTestCompareToString(a, b) < 0) { ... - virTestDifference(stderr, a, b); ... } and its variations (STRNEQ_NULLABLE() instead of STRNEQ(), then in some cases variables passed to STRNEQ() are in reversed order when compared to virTestCompareToString()). However, coccinelle failed to recognize the pattern in testNWFilterEBIPTablesAllTeardown() so I had to fix it manually. Also, I manually fixed testFormat() in tests/sockettest.c as I didn't bother writing another spatch rule just for that. Signed-off-by: Michal Privoznik Reviewed-by: Jonathon Jongsma --- tests/commandtest.c | 33 +++++++++++--------------------- tests/esxutilstest.c | 10 +++------- tests/nwfilterebiptablestest.c | 21 +++++++------------- tests/openvzutilstest.c | 6 ++---- tests/sockettest.c | 3 +-- tests/utiltest.c | 3 +-- tests/vboxsnapshotxmltest.c | 3 +-- tests/virbuftest.c | 21 +++++++------------- tests/virfirewalltest.c | 30 ++++++++++------------------- tests/virjsontest.c | 6 ++---- tests/virkmodtest.c | 3 +-- tests/virnetdevbandwidthtest.c | 3 +-- tests/virnetdevopenvswitchtest.c | 6 ++---- tests/virnetsockettest.c | 3 +-- tests/virshtest.c | 3 +-- 15 files changed, 51 insertions(+), 103 deletions(-) diff --git a/tests/commandtest.c b/tests/commandtest.c index ffc4b24ef4..62275ba96d 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -436,8 +436,7 @@ static int test13(const void *unused G_GNUC_UNUSED) =20 g_clear_pointer(&cmd, virCommandFree); =20 - if (STRNEQ(outactual, outexpect)) { - virTestDifference(stderr, outexpect, outactual); + if (virTestCompareToString(outexpect, outactual) < 0) { goto cleanup; } =20 @@ -497,16 +496,13 @@ static int test14(const void *unused G_GNUC_UNUSED) if (!jointactual) goto cleanup; =20 - if (STRNEQ(outactual, outexpect)) { - virTestDifference(stderr, outexpect, outactual); + if (virTestCompareToString(outexpect, outactual) < 0) { goto cleanup; } - if (STRNEQ(erractual, errexpect)) { - virTestDifference(stderr, errexpect, erractual); + if (virTestCompareToString(errexpect, erractual) < 0) { goto cleanup; } - if (STRNEQ(jointactual, jointexpect)) { - virTestDifference(stderr, jointexpect, jointactual); + if (virTestCompareToString(jointexpect, jointactual) < 0) { goto cleanup; } =20 @@ -569,8 +565,7 @@ static int test16(const void *unused G_GNUC_UNUSED) return -1; } =20 - if (STRNEQ(outactual, outexpect)) { - virTestDifference(stderr, outexpect, outactual); + if (virTestCompareToString(outexpect, outactual) < 0) { return -1; } =20 @@ -774,13 +769,11 @@ static int test21(const void *unused G_GNUC_UNUSED) if (virTestGetVerbose()) printf("STDOUT:%s\nSTDERR:%s\n", NULLSTR(outbuf), NULLSTR(errbuf)); =20 - if (STRNEQ_NULLABLE(outbuf, outbufExpected)) { - virTestDifference(stderr, outbufExpected, outbuf); + if (virTestCompareToString(outbufExpected, outbuf) < 0) { return -1; } =20 - if (STRNEQ_NULLABLE(errbuf, errbufExpected)) { - virTestDifference(stderr, errbufExpected, errbuf); + if (virTestCompareToString(errbufExpected, errbuf) < 0) { return -1; } =20 @@ -1016,8 +1009,7 @@ static int test26(const void *unused G_GNUC_UNUSED) return -1; } =20 - if (STRNEQ(outactual, outexpect)) { - virTestDifference(stderr, outexpect, outactual); + if (virTestCompareToString(outexpect, outactual) < 0) { return -1; } =20 @@ -1086,12 +1078,10 @@ static int test27(const void *unused G_GNUC_UNUSED) if (!outactual || !erractual) return -1; =20 - if (STRNEQ(outactual, outexpect)) { - virTestDifference(stderr, outexpect, outactual); + if (virTestCompareToString(outexpect, outactual) < 0) { return -1; } - if (STRNEQ(erractual, errexpect)) { - virTestDifference(stderr, errexpect, erractual); + if (virTestCompareToString(errexpect, erractual) < 0) { return -1; } =20 @@ -1225,8 +1215,7 @@ test29(const void *unused G_GNUC_UNUSED) } } =20 - if (STRNEQ_NULLABLE(outactual, outexpect)) { - virTestDifference(stderr, outexpect, outactual); + if (virTestCompareToString(outexpect, outactual) < 0) { goto cleanup; } =20 diff --git a/tests/esxutilstest.c b/tests/esxutilstest.c index 4591cf49db..5cebc10e44 100644 --- a/tests/esxutilstest.c +++ b/tests/esxutilstest.c @@ -50,19 +50,15 @@ testParseDatastorePath(const void *data G_GNUC_UNUSED) if (paths[i].result < 0) continue; =20 - if (STRNEQ(paths[i].datastoreName, datastoreName)) { - virTestDifference(stderr, paths[i].datastoreName, datastoreNam= e); + if (virTestCompareToString(paths[i].datastoreName, datastoreName) = < 0) { return -1; } =20 - if (STRNEQ(paths[i].directoryName, directoryName)) { - virTestDifference(stderr, paths[i].directoryName, directoryNam= e); + if (virTestCompareToString(paths[i].directoryName, directoryName) = < 0) { return -1; } =20 - if (STRNEQ(paths[i].directoryAndFileName, directoryAndFileName)) { - virTestDifference(stderr, paths[i].directoryAndFileName, - directoryAndFileName); + if (virTestCompareToString(paths[i].directoryAndFileName, director= yAndFileName) < 0) { return -1; } } diff --git a/tests/nwfilterebiptablestest.c b/tests/nwfilterebiptablestest.c index f76f13fd25..fe0d8e869c 100644 --- a/tests/nwfilterebiptablestest.c +++ b/tests/nwfilterebiptablestest.c @@ -107,8 +107,7 @@ testNWFilterEBIPTablesAllTeardown(const void *opaque G_= GNUC_UNUSED) =20 actual =3D virBufferContentAndReset(&buf); =20 - if (STRNEQ_NULLABLE(actual, expected)) { - virTestDifference(stderr, expected, actual); + if (virTestCompareToString(actual, expected) < 0) { return -1; } =20 @@ -169,8 +168,7 @@ testNWFilterEBIPTablesTearOldRules(const void *opaque G= _GNUC_UNUSED) =20 actual =3D virBufferContentAndReset(&buf); =20 - if (STRNEQ_NULLABLE(actual, expected)) { - virTestDifference(stderr, expected, actual); + if (virTestCompareToString(expected, actual) < 0) { return -1; } =20 @@ -209,8 +207,7 @@ testNWFilterEBIPTablesRemoveBasicRules(const void *opaq= ue G_GNUC_UNUSED) =20 actual =3D virBufferContentAndReset(&buf); =20 - if (STRNEQ_NULLABLE(actual, expected)) { - virTestDifference(stderr, expected, actual); + if (virTestCompareToString(expected, actual) < 0) { return -1; } =20 @@ -234,8 +231,7 @@ testNWFilterEBIPTablesTearNewRules(const void *opaque G= _GNUC_UNUSED) =20 actual =3D virBufferContentAndReset(&buf); =20 - if (STRNEQ_NULLABLE(actual, expected)) { - virTestDifference(stderr, expected, actual); + if (virTestCompareToString(expected, actual) < 0) { return -1; } =20 @@ -297,8 +293,7 @@ testNWFilterEBIPTablesApplyBasicRules(const void *opaqu= e G_GNUC_UNUSED) =20 actual =3D virBufferContentAndReset(&buf); =20 - if (STRNEQ_NULLABLE(actual, expected)) { - virTestDifference(stderr, expected, actual); + if (virTestCompareToString(expected, actual) < 0) { return -1; } =20 @@ -378,8 +373,7 @@ testNWFilterEBIPTablesApplyDHCPOnlyRules(const void *op= aque G_GNUC_UNUSED) =20 actual =3D virBufferContentAndReset(&buf); =20 - if (STRNEQ_NULLABLE(actual, expected)) { - virTestDifference(stderr, expected, actual); + if (virTestCompareToString(expected, actual) < 0) { return -1; } =20 @@ -442,8 +436,7 @@ testNWFilterEBIPTablesApplyDropAllRules(const void *opa= que G_GNUC_UNUSED) =20 actual =3D virBufferContentAndReset(&buf); =20 - if (STRNEQ_NULLABLE(actual, expected)) { - virTestDifference(stderr, expected, actual); + if (virTestCompareToString(expected, actual) < 0) { return -1; } =20 diff --git a/tests/openvzutilstest.c b/tests/openvzutilstest.c index 77e086e390..6ebfb0449f 100644 --- a/tests/openvzutilstest.c +++ b/tests/openvzutilstest.c @@ -49,8 +49,7 @@ testReadConfigParam(const void *data G_GNUC_UNUSED) if (configParams[i].ret !=3D 1) continue; =20 - if (STRNEQ(configParams[i].value, value)) { - virTestDifference(stderr, configParams[i].value, value); + if (virTestCompareToString(configParams[i].value, value) < 0) { return -1; } } @@ -114,8 +113,7 @@ testReadNetworkConf(const void *data G_GNUC_UNUSED) goto cleanup; } =20 - if (STRNEQ(expected, actual)) { - virTestDifference(stderr, expected, actual); + if (virTestCompareToString(expected, actual) < 0) { goto cleanup; } =20 diff --git a/tests/sockettest.c b/tests/sockettest.c index f2b75a2e53..6b9063e11d 100644 --- a/tests/sockettest.c +++ b/tests/sockettest.c @@ -48,8 +48,7 @@ static int testFormat(virSocketAddr *addr, const char *ad= drstr, bool pass) if (!newaddrstr) return pass ? -1 : 0; =20 - if (STRNEQ(newaddrstr, addrstr)) { - virTestDifference(stderr, addrstr, newaddrstr); + if (virTestCompareToString(newaddrstr, addrstr) < 0) { return pass ? -1 : 0; } else { return pass ? 0 : -1; diff --git a/tests/utiltest.c b/tests/utiltest.c index e7a79f808f..e90baca65f 100644 --- a/tests/utiltest.c +++ b/tests/utiltest.c @@ -47,8 +47,7 @@ testIndexToDiskName(const void *data G_GNUC_UNUSED) =20 diskName =3D virIndexToDiskName(i, "sd"); =20 - if (STRNEQ(diskNames[i], diskName)) { - virTestDifference(stderr, diskNames[i], diskName); + if (virTestCompareToString(diskNames[i], diskName) < 0) { return -1; } } diff --git a/tests/vboxsnapshotxmltest.c b/tests/vboxsnapshotxmltest.c index 3ad8298895..ab65999df1 100644 --- a/tests/vboxsnapshotxmltest.c +++ b/tests/vboxsnapshotxmltest.c @@ -69,8 +69,7 @@ testCompareXMLtoXMLFiles(const char *xml) if (!(xmlData =3D testFilterXML(xmlData))) goto cleanup; =20 - if (STRNEQ(actual, xmlData)) { - virTestDifference(stderr, xmlData, actual); + if (virTestCompareToString(xmlData, actual) < 0) { goto cleanup; } =20 diff --git a/tests/virbuftest.c b/tests/virbuftest.c index 144df6e66b..6b810381fb 100644 --- a/tests/virbuftest.c +++ b/tests/virbuftest.c @@ -92,8 +92,7 @@ static int testBufAutoIndent(const void *data G_GNUC_UNUS= ED) virBufferAddChar(buf, '\n'); =20 result =3D virBufferContentAndReset(buf); - if (STRNEQ_NULLABLE(result, expected)) { - virTestDifference(stderr, expected, result); + if (virTestCompareToString(expected, result) < 0) { ret =3D -1; } return ret; @@ -122,8 +121,7 @@ static int testBufTrim(const void *data G_GNUC_UNUSED) virBufferTrim(buf, ",,"); =20 result =3D virBufferContentAndReset(buf); - if (STRNEQ_NULLABLE(result, expected)) { - virTestDifference(stderr, expected, result); + if (virTestCompareToString(expected, result) < 0) { return -1; } =20 @@ -145,8 +143,7 @@ testBufTrimChars(const void *opaque) return -1; } =20 - if (STRNEQ_NULLABLE(actual, data->expect)) { - virTestDifference(stderr, data->expect, actual); + if (virTestCompareToString(data->expect, actual) < 0) { return -1; } =20 @@ -250,8 +247,7 @@ static int testBufAddBuffer(const void *data G_GNUC_UNU= SED) } =20 result =3D virBufferContentAndReset(&buf1); - if (STRNEQ_NULLABLE(result, expected)) { - virTestDifference(stderr, expected, result); + if (virTestCompareToString(expected, result) < 0) { return -1; } =20 @@ -276,8 +272,7 @@ testBufAddStr(const void *opaque) return -1; } =20 - if (STRNEQ_NULLABLE(actual, data->expect)) { - virTestDifference(stderr, data->expect, actual); + if (virTestCompareToString(data->expect, actual) < 0) { return -1; } =20 @@ -303,8 +298,7 @@ testBufEscapeStr(const void *opaque) return -1; } =20 - if (STRNEQ_NULLABLE(actual, data->expect)) { - virTestDifference(stderr, data->expect, actual); + if (virTestCompareToString(data->expect, actual) < 0) { return -1; } =20 @@ -326,8 +320,7 @@ testBufEscapeRegex(const void *opaque) return -1; } =20 - if (STRNEQ_NULLABLE(actual, data->expect)) { - virTestDifference(stderr, data->expect, actual); + if (virTestCompareToString(data->expect, actual) < 0) { return -1; } =20 diff --git a/tests/virfirewalltest.c b/tests/virfirewalltest.c index e3d15fb67b..51c8006331 100644 --- a/tests/virfirewalltest.c +++ b/tests/virfirewalltest.c @@ -89,9 +89,8 @@ testFirewallSingleGroup(const void *opaque G_GNUC_UNUSED) =20 actual =3D virBufferCurrentContent(&cmdbuf); =20 - if (STRNEQ_NULLABLE(expected, actual)) { + if (virTestCompareToString(expected, actual) < 0) { fprintf(stderr, "Unexpected command execution\n"); - virTestDifference(stderr, expected, actual); return -1; } =20 @@ -136,9 +135,8 @@ testFirewallRemoveRule(const void *opaque G_GNUC_UNUSED) =20 actual =3D virBufferCurrentContent(&cmdbuf); =20 - if (STRNEQ_NULLABLE(expected, actual)) { + if (virTestCompareToString(expected, actual) < 0) { fprintf(stderr, "Unexpected command execution\n"); - virTestDifference(stderr, expected, actual); return -1; } =20 @@ -190,9 +188,8 @@ testFirewallManyGroups(const void *opaque G_GNUC_UNUSED) =20 actual =3D virBufferCurrentContent(&cmdbuf); =20 - if (STRNEQ_NULLABLE(expected, actual)) { + if (virTestCompareToString(expected, actual) < 0) { fprintf(stderr, "Unexpected command execution\n"); - virTestDifference(stderr, expected, actual); return -1; } =20 @@ -265,9 +262,8 @@ testFirewallIgnoreFailGroup(const void *opaque G_GNUC_U= NUSED) =20 actual =3D virBufferCurrentContent(&cmdbuf); =20 - if (STRNEQ_NULLABLE(expected, actual)) { + if (virTestCompareToString(expected, actual) < 0) { fprintf(stderr, "Unexpected command execution\n"); - virTestDifference(stderr, expected, actual); return -1; } =20 @@ -318,9 +314,8 @@ testFirewallIgnoreFailRule(const void *opaque G_GNUC_UN= USED) =20 actual =3D virBufferCurrentContent(&cmdbuf); =20 - if (STRNEQ_NULLABLE(expected, actual)) { + if (virTestCompareToString(expected, actual) < 0) { fprintf(stderr, "Unexpected command execution\n"); - virTestDifference(stderr, expected, actual); return -1; } =20 @@ -365,9 +360,8 @@ testFirewallNoRollback(const void *opaque G_GNUC_UNUSED) =20 actual =3D virBufferCurrentContent(&cmdbuf); =20 - if (STRNEQ_NULLABLE(expected, actual)) { + if (virTestCompareToString(expected, actual) < 0) { fprintf(stderr, "Unexpected command execution\n"); - virTestDifference(stderr, expected, actual); return -1; } =20 @@ -431,9 +425,8 @@ testFirewallSingleRollback(const void *opaque G_GNUC_UN= USED) =20 actual =3D virBufferCurrentContent(&cmdbuf); =20 - if (STRNEQ_NULLABLE(expected, actual)) { + if (virTestCompareToString(expected, actual) < 0) { fprintf(stderr, "Unexpected command execution\n"); - virTestDifference(stderr, expected, actual); return -1; } =20 @@ -500,9 +493,8 @@ testFirewallManyRollback(const void *opaque G_GNUC_UNUS= ED) =20 actual =3D virBufferCurrentContent(&cmdbuf); =20 - if (STRNEQ_NULLABLE(expected, actual)) { + if (virTestCompareToString(expected, actual) < 0) { fprintf(stderr, "Unexpected command execution\n"); - virTestDifference(stderr, expected, actual); return -1; } =20 @@ -599,9 +591,8 @@ testFirewallChainedRollback(const void *opaque G_GNUC_U= NUSED) =20 actual =3D virBufferCurrentContent(&cmdbuf); =20 - if (STRNEQ_NULLABLE(expected, actual)) { + if (virTestCompareToString(expected, actual) < 0) { fprintf(stderr, "Unexpected command execution\n"); - virTestDifference(stderr, expected, actual); return -1; } =20 @@ -763,9 +754,8 @@ testFirewallQuery(const void *opaque G_GNUC_UNUSED) return -1; } =20 - if (STRNEQ_NULLABLE(expected, actual)) { + if (virTestCompareToString(expected, actual) < 0) { fprintf(stderr, "Unexpected command execution\n"); - virTestDifference(stderr, expected, actual); return -1; } =20 diff --git a/tests/virjsontest.c b/tests/virjsontest.c index 78283b632a..294889a795 100644 --- a/tests/virjsontest.c +++ b/tests/virjsontest.c @@ -93,8 +93,7 @@ testJSONFromString(const void *data) return -1; } =20 - if (STRNEQ(expectstr, formatted)) { - virTestDifference(stderr, expectstr, formatted); + if (virTestCompareToString(expectstr, formatted) < 0) { return -1; } =20 @@ -424,8 +423,7 @@ testJSONEscapeObj(const void *data G_GNUC_UNUSED) return -1; } =20 - if (STRNEQ(parsednestedstr, neststr)) { - virTestDifference(stderr, neststr, parsednestedstr); + if (virTestCompareToString(neststr, parsednestedstr) < 0) { return -1; } =20 diff --git a/tests/virkmodtest.c b/tests/virkmodtest.c index 0e662878b2..ec28ef1282 100644 --- a/tests/virkmodtest.c +++ b/tests/virkmodtest.c @@ -40,8 +40,7 @@ checkOutput(virBuffer *buf, const char *exp_cmd) return -1; } =20 - if (STRNEQ(exp_cmd, actual_cmd)) { - virTestDifference(stderr, exp_cmd, actual_cmd); + if (virTestCompareToString(exp_cmd, actual_cmd) < 0) { return -1; } =20 diff --git a/tests/virnetdevbandwidthtest.c b/tests/virnetdevbandwidthtest.c index fced657811..f7c38faa2e 100644 --- a/tests/virnetdevbandwidthtest.c +++ b/tests/virnetdevbandwidthtest.c @@ -92,8 +92,7 @@ testVirNetDevBandwidthSet(const void *data) * Maybe that's expected, actually. */ } =20 - if (STRNEQ_NULLABLE(exp_cmd, actual_cmd)) { - virTestDifference(stderr, exp_cmd, actual_cmd); + if (virTestCompareToString(exp_cmd, actual_cmd) < 0) { return -1; } =20 diff --git a/tests/virnetdevopenvswitchtest.c b/tests/virnetdevopenvswitcht= est.c index e5883eb076..6e93f5e65a 100644 --- a/tests/virnetdevopenvswitchtest.c +++ b/tests/virnetdevopenvswitchtest.c @@ -175,8 +175,7 @@ testVirNetDevOpenvswitchInterfaceSetQos(const void *dat= a) * Maybe that's expected, actually. */ } =20 - if (STRNEQ_NULLABLE(info->exp_cmd, actual_cmd)) { - virTestDifference(stderr, info->exp_cmd, actual_cmd); + if (virTestCompareToString(info->exp_cmd, actual_cmd) < 0) { return -1; } =20 @@ -204,8 +203,7 @@ testVirNetDevOpenvswitchInterfaceClearQos(const void *d= ata) * Maybe that's expected, actually. */ } =20 - if (STRNEQ_NULLABLE(info->exp_cmd, actual_cmd)) { - virTestDifference(stderr, info->exp_cmd, actual_cmd); + if (virTestCompareToString(info->exp_cmd, actual_cmd) < 0) { return -1; } =20 diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index 396005899a..2295e29777 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -488,8 +488,7 @@ static int testSocketSSH(const void *opaque) } buf[rv] =3D '\0'; =20 - if (STRNEQ(buf, data->expectOut)) { - virTestDifference(stderr, data->expectOut, buf); + if (virTestCompareToString(data->expectOut, buf) < 0) { goto cleanup; } =20 diff --git a/tests/virshtest.c b/tests/virshtest.c index 3d297a1db2..cf834bb847 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -134,8 +134,7 @@ testCompareOutputLit(const char *expectData, if (filter && testFilterLine(actualData, filter) < 0) return -1; =20 - if (STRNEQ(expectData, actualData)) { - virTestDifference(stderr, expectData, actualData); + if (virTestCompareToString(expectData, actualData) < 0) { return -1; } =20 --=20 2.37.4