From nobody Sat May 18 13:16:24 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=1692867474; cv=none; d=zohomail.com; s=zohoarc; b=mtCgQrJ/qY1ZZHOnsxEQiHc1niRIZy5LN3ryr1IPH3Fq33IDOYCB5+X5qjLLgGZOLbF58YpG1/PPvacbaDfX0VGWxfDMw35rVpfG/sh4pLKyHxJHb3O/D+tsidoP3UA25h7C3ZKRxpS325eEyYgl+Zi+/TXjuQaBt2QbR3/cgAE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692867474; 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=SabIyr+GiEaq2hePVsOgV+cvX80DTfxTARzC+SaTOfM=; b=Q309n4Qsw5YWtnzsJqjYoiuae08GU91WSzU2/DxWzmhp7tnfxIP3aEyk09lDigGUGe15phNnC9TbMk7Zz0O9kYWelBhCq4NvVHreuoC73J+8+pU9zXLwmoH6pc4UNwjjoJcLVN07fcOLvA/vIftxJRBrGQf4WEXdDcHLTib6UCQ= 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 1692867474870208.3298002545347; Thu, 24 Aug 2023 01:57:54 -0700 (PDT) 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-241-vaUX34P2NlmZjbjFcvAoRw-1; Thu, 24 Aug 2023 04:57:48 -0400 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 EF9AD85CBE9; Thu, 24 Aug 2023 08:57:44 +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 D804C2026D68; Thu, 24 Aug 2023 08:57:44 +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 97301194658D; Thu, 24 Aug 2023 08:57:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2D2731946589 for ; Thu, 24 Aug 2023 08:57:43 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1D5271121314; Thu, 24 Aug 2023 08:57:43 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8C1A1121315 for ; Thu, 24 Aug 2023 08:57:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692867473; 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=SabIyr+GiEaq2hePVsOgV+cvX80DTfxTARzC+SaTOfM=; b=H3UmKMRTusYubKLVfP72UK6YKyINlnnRvmDfaM8hZ1KFNfb1I16ubFD9Cqj9gwz0qiyPe5 o7ML0lEXYJOC40QV+iftEJ1aIjlXPoRqOnHkNdNtlVoJdAsuM3c2XP7zPfgzLBP2/f7xWV pFx1k9c5gGbf2Cb7JOHnDILq+VgUv44= X-MC-Unique: vaUX34P2NlmZjbjFcvAoRw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/6] nodedevmdevctltest: Rename mdevctl-list-empty test case Date: Thu, 24 Aug 2023 10:57:35 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: 1692867476989100009 Content-Type: text/plain; charset="utf-8"; x-default="true" The mdevctl-list-empty test case is there to test whether an empty JSON array "[]" is handled correctly by mdevctl handling code. Well, mdevctl can output both, an empty JSON array or no output at all. Therefore, rename "mdevctl-list-empty" test case to "mdevctl-list-empty-array" which is more descriptive and also frees up slot for actual empty output (handled in next commits). Signed-off-by: Michal Privoznik Reviewed-by: Kristina Hanicova --- .../{mdevctl-list-empty.json =3D> mdevctl-list-empty-array.json} | 0 ...vctl-list-empty.out.xml =3D> mdevctl-list-empty-array.out.xml} | 0 tests/nodedevmdevctltest.c | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename tests/nodedevmdevctldata/{mdevctl-list-empty.json =3D> mdevctl-list= -empty-array.json} (100%) rename tests/nodedevmdevctldata/{mdevctl-list-empty.out.xml =3D> mdevctl-l= ist-empty-array.out.xml} (100%) diff --git a/tests/nodedevmdevctldata/mdevctl-list-empty.json b/tests/noded= evmdevctldata/mdevctl-list-empty-array.json similarity index 100% rename from tests/nodedevmdevctldata/mdevctl-list-empty.json rename to tests/nodedevmdevctldata/mdevctl-list-empty-array.json diff --git a/tests/nodedevmdevctldata/mdevctl-list-empty.out.xml b/tests/no= dedevmdevctldata/mdevctl-list-empty-array.out.xml similarity index 100% rename from tests/nodedevmdevctldata/mdevctl-list-empty.out.xml rename to tests/nodedevmdevctldata/mdevctl-list-empty-array.out.xml diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index 4dc524b5a5..c04b05c417 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -470,7 +470,7 @@ mymain(void) =20 DO_TEST_LIST_DEFINED(); =20 - DO_TEST_PARSE_JSON("mdevctl-list-empty"); + DO_TEST_PARSE_JSON("mdevctl-list-empty-array"); DO_TEST_PARSE_JSON("mdevctl-list-multiple"); =20 DO_TEST_DEFINE("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366"); --=20 2.41.0 From nobody Sat May 18 13:16:24 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=1692867473; cv=none; d=zohomail.com; s=zohoarc; b=ir/YV6qL6oj35sFVvqgK8wzM7j/7AWRgzUTcW/rQNvqWeAKzKZs8/EcxiGWtkwj5Py43tvKa7/ycuRrOADWBfqKAExX6lj6p1cEgYBEi6VRPT9TfaYP7qr7E6nwB+++I8eznw0AqChkLH+LyzSAosLj2fo37lbp3d5p+dakMMZo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692867473; 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=bPIzlum2CXGD91n/9qRXq/Hr16nJ7TBuFM3Mj8svbbg=; b=nc32RZuahhf9PhIoDskZpL9tkaz9ek7W2aIeBgif72U8LS2COVfHaJcjYdI168vAowDJcH8Ack2FuV0/qmSlrgcfPILh0oy+bhH9RKxWcEL9+uf4FhpFEBfcKint08yiwvK8vZL/1WJfH+f8LdvIp4k+pTF6sTDxYznnU8e0C/w= 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 1692867473894866.0022808440899; Thu, 24 Aug 2023 01:57:53 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [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-86-Cefe9lZzNGyGveCP2A_1IA-1; Thu, 24 Aug 2023 04:57:48 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7FF142808E69; Thu, 24 Aug 2023 08:57:45 +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 6C80E40D2839; Thu, 24 Aug 2023 08:57:45 +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 5118D194658C; Thu, 24 Aug 2023 08:57:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CA9201946589 for ; Thu, 24 Aug 2023 08:57:43 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id AC6901121319; Thu, 24 Aug 2023 08:57:43 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 543AF1121314 for ; Thu, 24 Aug 2023 08:57:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692867472; 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=bPIzlum2CXGD91n/9qRXq/Hr16nJ7TBuFM3Mj8svbbg=; b=B03uBpmyrTHYJZMcFxwaXQ1fU0pNuSg4C12+5h+mzY+I3RCG+BHYVi7a5d4An7vT0Q9wDT zU0W+qIchmJTa88Xaf0AW7F+qjsKvLcvKAOcvNwQBKVvHoOjjNaplsJbsvdK8M+lIgTsa5 ci4/cbbGbERXpUXoP+0X6Mf6laQqGf4= X-MC-Unique: Cefe9lZzNGyGveCP2A_1IA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/6] nodeDeviceParseMdevctlJSON: Accept empty string Date: Thu, 24 Aug 2023 10:57:36 +0200 Message-ID: <3ad475ebf334fff1aa7eafc344ef32dc5d49ff46.1692867419.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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.2 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: 1692867475554100006 Content-Type: text/plain; charset="utf-8"; x-default="true" It is possible for 'mdevctl' to output nothing, an empty string (e.g. when no mediated devices are defined on the host). What is weird is that when passing '--defined' then 'mdevctl' outputs an empty JSON array instead. Nevertheless, we should accept both and threat them the same, i.e. as no mediated devices. Resolves: https://gitlab.com/libvirt/libvirt/-/issues/523 Signed-off-by: Michal Privoznik Reviewed-by: Kristina Hanicova --- src/node_device/node_device_driver.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 2ef9197adc..593bc64e25 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -43,6 +43,7 @@ #include "virutil.h" #include "vircommand.h" #include "virlog.h" +#include "virstring.h" =20 #define VIR_FROM_THIS VIR_FROM_NODEDEV =20 @@ -1176,6 +1177,12 @@ nodeDeviceParseMdevctlJSON(const char *jsonstring, size_t j; virJSONValue *obj; =20 + if (virStringIsEmpty(jsonstring)) { + VIR_DEBUG("mdevctl has no defined mediated devices"); + *devs =3D NULL; + return 0; + } + json_devicelist =3D virJSONValueFromString(jsonstring); =20 if (!json_devicelist || !virJSONValueIsArray(json_devicelist)) { --=20 2.41.0 From nobody Sat May 18 13:16:24 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=1692867472; cv=none; d=zohomail.com; s=zohoarc; b=P7mMSLMOts+gOHC62NjxPVgk3QaeVCLGkwUTuwzirR7vCvV5xZHWriXgrEtZDnD6x55YE5dSktAhIZcD04xY07MUEoSHxNz2lnEPEc+VGbEB28vxsSTEalGvyB5B7EDvBnpB1pXsU50w+yg4ynuNJKFd9RzcJp+tV3lIfQ8WZfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692867472; 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=D16oHfRZuRWWkMoHD8K0YWolhKWkJjzDEmfCXuQejQA=; b=WMYTTHBj5A3RH+ZPKRJC34TCWsLuX1fLAE8tJV3tViGPGe8Kx7ZippqlRLD9R6CF7F7qedV/aYhEoeXnNeQDdTOJajwiKhvbyMkvKai4VAVxs2NedbPKf8e7oePJlrJ0XZFiVBYlc7XcLvyKzly9iHMJF3pYr2edbV84ebUfeXU= 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 1692867472860482.647196720653; Thu, 24 Aug 2023 01:57:52 -0700 (PDT) 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-361-ybFxsJK1P7CZdcKXkUpNDw-1; Thu, 24 Aug 2023 04:57:48 -0400 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 2472F185A7AE; Thu, 24 Aug 2023 08:57:46 +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 11BA41121315; Thu, 24 Aug 2023 08:57:46 +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 CD4CE194658C; Thu, 24 Aug 2023 08:57:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6C7B41946589 for ; Thu, 24 Aug 2023 08:57:44 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4863D1121319; Thu, 24 Aug 2023 08:57:44 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id E345E1121314 for ; Thu, 24 Aug 2023 08:57:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692867471; 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=D16oHfRZuRWWkMoHD8K0YWolhKWkJjzDEmfCXuQejQA=; b=DkAvN/ztS0N5q3GL9jM2CVU5rtbepP4DsoyNZP6iiyoWVd2OCArIIAX2+HzCG1GL8lxvfD f5hXy1uZYXh6FyobN+TVJXuH+ErphalOWOW5RoNkejJ0Pxc10M26TCP57d4R+spfaoQQXE dxVv/X+OUavI/qOqZwCdblNMRHmCfrE= X-MC-Unique: ybFxsJK1P7CZdcKXkUpNDw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/6] nodedevmdevctltest: Introduce a test case for empty mdevctl output Date: Thu, 24 Aug 2023 10:57:37 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: 1692867474977100001 Content-Type: text/plain; charset="utf-8"; x-default="true" As explained earlier, 'mdevctl' can output nothing. Add a test case to nodedevmdevctltest which covers this situation. Signed-off-by: Michal Privoznik Reviewed-by: Kristina Hanicova --- tests/nodedevmdevctldata/mdevctl-list-empty.json | 0 tests/nodedevmdevctldata/mdevctl-list-empty.out.xml | 0 tests/nodedevmdevctltest.c | 1 + 3 files changed, 1 insertion(+) create mode 100644 tests/nodedevmdevctldata/mdevctl-list-empty.json create mode 100644 tests/nodedevmdevctldata/mdevctl-list-empty.out.xml diff --git a/tests/nodedevmdevctldata/mdevctl-list-empty.json b/tests/noded= evmdevctldata/mdevctl-list-empty.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/nodedevmdevctldata/mdevctl-list-empty.out.xml b/tests/no= dedevmdevctldata/mdevctl-list-empty.out.xml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index c04b05c417..e403328e5a 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -470,6 +470,7 @@ mymain(void) =20 DO_TEST_LIST_DEFINED(); =20 + DO_TEST_PARSE_JSON("mdevctl-list-empty"); DO_TEST_PARSE_JSON("mdevctl-list-empty-array"); DO_TEST_PARSE_JSON("mdevctl-list-multiple"); =20 --=20 2.41.0 From nobody Sat May 18 13:16:24 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=1692867473; cv=none; d=zohomail.com; s=zohoarc; b=jMTKwuKB9R9pKM7maWYEAy/Z6K5slRFBu3CWiDQ4bxLETIwp+7Ep6spp8zqnaZPDfHWQc5wBW6F2vRPh5ewhJjvoljiYe9YigVe9AqxNWWoY10nKcQRa26Enn0zqClyfOQqc/dAKve74B47pcCcilo/b2KLRvj+MoHT8dnz/9X8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692867473; 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=r8kpM9GQan1L/4Y0hN64JKNopZcNLQMA9cUXdi/AS94=; b=jSCvPraqOUPPhSPsCxo8/5z2inkqiCkZ88TRlLaJlB8mv4ZxMk4+faAWr+9oPx2HNTHygUlXaCuALxph5u9Re8G2Hn8cZfzXktwgWoTscBWV2B0VEdnOXq+4S8okCiSthYDQNMiJCxzT4fkas2vkCXqKyB1oeZ8Pu6eelc2BpNo= 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 1692867473795414.57010822138227; Thu, 24 Aug 2023 01:57:53 -0700 (PDT) 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-154-VhZnC3vNPpu-4CbG9OG2JQ-1; Thu, 24 Aug 2023 04:57:51 -0400 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 E1D218D40A1; Thu, 24 Aug 2023 08:57:47 +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 C8FE82026D2C; Thu, 24 Aug 2023 08:57:47 +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 874CF194658C; Thu, 24 Aug 2023 08:57:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E924A1946589 for ; Thu, 24 Aug 2023 08:57:44 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D65771121315; Thu, 24 Aug 2023 08:57:44 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7DD501121314 for ; Thu, 24 Aug 2023 08:57:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692867472; 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=r8kpM9GQan1L/4Y0hN64JKNopZcNLQMA9cUXdi/AS94=; b=WXK5iJ5RyPffrx9x794/IhqbAMoHq/cIwMPKd8M0ObZggtc3wKZqI/iSSfpfYLFHf5s28A qP6T45FFrqhfDrVWUONg6zTgzuNJky9p3ucIGmf+rwjjJozXbgHq2/+T6Y4728XUZINLig a1mbBwmT0olKbk1IyIRGCr5kbiq3/M4= X-MC-Unique: VhZnC3vNPpu-4CbG9OG2JQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/6] node_device_driver: Deduplicate mediated devices listing Date: Thu, 24 Aug 2023 10:57:38 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: 1692867475480100004 Content-Type: text/plain; charset="utf-8"; x-default="true" We have virMdevctlListDefined() to list defined mdevs, and virMdevctlListActive() to list active mdevs. Both have the same body except for one boolean argument passed to nodeDeviceGetMdevctlListCommand(). Join the two functions under virMdevctlList() name and introduce @defined argument that is then just passed to the cmd line builder function. Signed-off-by: Michal Privoznik Reviewed-by: Kristina Hanicova --- src/node_device/node_device_driver.c | 30 ++++++---------------------- 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 593bc64e25..ac50c96837 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -1636,32 +1636,14 @@ nodeDeviceGenerateName(virNodeDeviceDef *def, =20 =20 static int -virMdevctlListDefined(virNodeDeviceDef ***devs, char **errmsg) +virMdevctlList(bool defined, + virNodeDeviceDef ***devs, + char **errmsg) { int status; g_autofree char *output =3D NULL; g_autofree char *errbuf =3D NULL; - g_autoptr(virCommand) cmd =3D nodeDeviceGetMdevctlListCommand(true, &o= utput, &errbuf); - - if (virCommandRun(cmd, &status) < 0 || status !=3D 0) { - *errmsg =3D g_steal_pointer(&errbuf); - return -1; - } - - if (!output) - return -1; - - return nodeDeviceParseMdevctlJSON(output, devs); -} - - -static int -virMdevctlListActive(virNodeDeviceDef ***devs, char **errmsg) -{ - int status; - g_autofree char *output =3D NULL; - g_autofree char *errbuf =3D NULL; - g_autoptr(virCommand) cmd =3D nodeDeviceGetMdevctlListCommand(false, &= output, &errbuf); + g_autoptr(virCommand) cmd =3D nodeDeviceGetMdevctlListCommand(defined,= &output, &errbuf); =20 if (virCommandRun(cmd, &status) < 0 || status !=3D 0) { *errmsg =3D g_steal_pointer(&errbuf); @@ -1750,7 +1732,7 @@ nodeDeviceUpdateMediatedDevices(void) return 0; } =20 - if ((data.ndefs =3D virMdevctlListDefined(&defs, &errmsg)) < 0) { + if ((data.ndefs =3D virMdevctlList(true, &defs, &errmsg)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to query mdevs from mdevctl: %1$s"), errm= sg); return -1; @@ -1767,7 +1749,7 @@ nodeDeviceUpdateMediatedDevices(void) return -1; =20 /* Update active/transient mdev devices */ - if ((act_ndefs =3D virMdevctlListActive(&act_defs, &errmsg)) < 0) { + if ((act_ndefs =3D virMdevctlList(false, &act_defs, &errmsg)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to query mdevs from mdevctl: %1$s"), errm= sg); return -1; --=20 2.41.0 From nobody Sat May 18 13:16:24 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=1692867491; cv=none; d=zohomail.com; s=zohoarc; b=lsS6/ybdsvSQICV2tOf9eqLme5l2rrNNOw8PL4c9WQUag1EF9918ycNJbP5iXj/EU7ejeInSKqwFVSze8SNycLjbIskgWEbiqCgT5tS37Wb0qjqd77ApoBAkZ5Cj31zUUSZ16tckZ3WP2uFYKBomx7+15T28MX/7jd8HGWh3n3U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692867491; 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=ZsJbq+CbFJtiDNVxcTYYl42YvoFsZkhHEnA96IJ7oVw=; b=WXnJSL/pF5Kv7oagBlKLFVnk7McRg88I321NYonTl5o0fpFbvM6glz6wUlG1wFMDtkc5xwpRsWVyaN2w4/e4EgXRyn5pb2z/xY2Z0NmwB++Nf88C9yZsR2hRqEeGMlpHK15TS+FS3pN8olnvlaK9E4XSe8gddT3dzrrK6IgVNtA= 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 1692867491320726.3996546725434; Thu, 24 Aug 2023 01:58:11 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [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-302-W3LM_KMkNN28JKqklgkVvA-1; Thu, 24 Aug 2023 04:57:51 -0400 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 4401E1C08971; Thu, 24 Aug 2023 08:57:48 +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 29787403163; Thu, 24 Aug 2023 08:57:48 +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 BDC4219465B5; Thu, 24 Aug 2023 08:57:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9F3831946589 for ; Thu, 24 Aug 2023 08:57:45 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 709DA1121315; Thu, 24 Aug 2023 08:57:45 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 182A11121314 for ; Thu, 24 Aug 2023 08:57:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692867490; 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=ZsJbq+CbFJtiDNVxcTYYl42YvoFsZkhHEnA96IJ7oVw=; b=RagoeB72YshYQpPokKRTmpaGDYtpyN0toYSNKItLZ6Es9ErcZ17aXrDL27jcv6wnoJLSaS NVXUJ0EeHwku7+jyVpGIv4iKEEStB8dfEcxDBAy/Snkn0nx7TsHc8ULt7ovZe0/vdFwyZ0 lLMeLGY6gLlTogeReL6zHE/xn1rrv+Q= X-MC-Unique: W3LM_KMkNN28JKqklgkVvA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 5/6] virMdevctlList: Don't check for !output Date: Thu, 24 Aug 2023 10:57:39 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: 1692867491553100001 Content-Type: text/plain; charset="utf-8"; x-default="true" After 'mdevctl' was ran, its stdout is captured in @output which is then compared against NULL and if it is NULL a negative value is returned (to indicate error to the caller). But this is effectively a dead code, because virCommand (specifically virCommandProcessIO()) makes sure both stdout and stderr buffers are properly '\0' terminated. Therefore, this can never evaluate to true. Also, if there really is no output from 'mdevctl' (which was handled in one of earlier commits, but let just assume it wasn't), then we should not error out and treat such scenario as 'no mdevs defined/active'. Signed-off-by: Michal Privoznik Reviewed-by: Kristina Hanicova --- src/node_device/node_device_driver.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index ac50c96837..a59cd0875d 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -1650,9 +1650,6 @@ virMdevctlList(bool defined, return -1; } =20 - if (!output) - return -1; - return nodeDeviceParseMdevctlJSON(output, devs); } =20 --=20 2.41.0 From nobody Sat May 18 13:16:24 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=1692867480; cv=none; d=zohomail.com; s=zohoarc; b=SM7jxc9CnqGNWOJsZp5dG3WegJ5SE8+zIrGW0v4YDTgHD7IabJXm2Lgg3V8QtIbntQcaf4KAbGMV8ZPQfS3k3yRDB2h2VRk0Bz5PMpDYO8k7tVApb/OufC5oc1uWa7auYT1Ea5VrdIa6BtnZzK5CFnhnUJrrSXMkqMyZ02HHahI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692867480; 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=DB02TSbXtPk9s/A58iKZQ7sfNVLQP4aac3QUBDpKRKQ=; b=aob/3Fc3d4xhaErfQQONp3TjmtYZe1XoqBamx9I+cJ9oP3sYBpd0Ww8zYZyVSlgAqkipvQ5lDAoatxa94Zhnw/U85tL4yY6wQ/ZRjBfJEENLfEsJ68DBBbcZ24jAkrDalLWEelKd0A2nK4BTmNcvt2TXby7qFarDT+rH6J/IM4M= 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 1692867480859916.8405838737216; Thu, 24 Aug 2023 01:58:00 -0700 (PDT) Received: from mimecast-mx02.redhat.com (66.187.233.73 [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-654-TgWoZQ4vPimL1ycAOvjSBA-1; Thu, 24 Aug 2023 04:57:51 -0400 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 876581C0140E; Thu, 24 Aug 2023 08:57:48 +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 6EE93140E922; Thu, 24 Aug 2023 08:57:48 +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 062A51946594; Thu, 24 Aug 2023 08:57:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3896C1946589 for ; Thu, 24 Aug 2023 08:57:46 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0BFC21121314; Thu, 24 Aug 2023 08:57:46 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6B9B1121315 for ; Thu, 24 Aug 2023 08:57:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692867479; 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=DB02TSbXtPk9s/A58iKZQ7sfNVLQP4aac3QUBDpKRKQ=; b=LuF3gt2u4hTvsn79T+XVc3iPR3txtN5U8aiBZE/q4TUFH/9ddTNX5KT6PYWuS8h2rm7ZeL 1GFT/72GsTvIm/42k2eCQ9svwMbA1JDapu65J3tSE1mM/1gH5QhPg1YhDpxFsQUZTzUYFs l9i50JCWxOR9L1NbOv0WMSEjSYmEqy0= X-MC-Unique: TgWoZQ4vPimL1ycAOvjSBA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 6/6] virjsontest: Introduce a test case for an empty array Date: Thu, 24 Aug 2023 10:57:40 +0200 Message-ID: <6ad200263b8c657c0ee3264ad5490819c2620f15.1692867419.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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: 1692867481500100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Previous commits were all about empty strings and empty JSON arrays. Introduce a test case for "[]" to make sure we pare it correctly. Signed-off-by: Michal Privoznik Reviewed-by: Kristina Hanicova --- tests/virjsontest.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/virjsontest.c b/tests/virjsontest.c index 294889a795..6b6a64d3d3 100644 --- a/tests/virjsontest.c +++ b/tests/virjsontest.c @@ -553,6 +553,7 @@ mymain(void) DO_TEST_PARSE("integer", "1", NULL); DO_TEST_PARSE("boolean", "true", NULL); DO_TEST_PARSE("null", "null", NULL); + DO_TEST_PARSE("[]", "[]", NULL); =20 DO_TEST_PARSE("escaping symbols", "[\"\\\"\\t\\n\\\\\"]", NULL); DO_TEST_PARSE("escaped strings", "[\"{\\\"blurb\\\":\\\"test\\\"}\"]",= NULL); --=20 2.41.0