From nobody Sun Feb 8 17:14:39 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1709911148127860.564933799243; Fri, 8 Mar 2024 07:19:08 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 035F81DF8; Fri, 8 Mar 2024 10:19:06 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A09741B8B; Fri, 8 Mar 2024 10:15:45 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 170321AE2; Fri, 8 Mar 2024 10:15:32 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 592831AF8 for ; Fri, 8 Mar 2024 10:15:31 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-252-2GfCfWCiPj-DpYSDeakx5Q-1; Fri, 08 Mar 2024 10:15:29 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 76E8A8007A6 for ; Fri, 8 Mar 2024 15:15:29 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1EF101C05E1C for ; Fri, 8 Mar 2024 15:15:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: 2GfCfWCiPj-DpYSDeakx5Q-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 1/4] tests: Introduce chxml2xmlmock Date: Fri, 8 Mar 2024 16:15:23 +0100 Message-ID: <6bdb552d472296a9e02b663e4467d85d942885a1.1709910136.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: MKKEQCLSVD673LLK4HE2GYPKCCUVDK3S X-Message-ID-Hash: MKKEQCLSVD673LLK4HE2GYPKCCUVDK3S X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1709911149566100001 As of previous commit, the CH driver checks for /dev/kvm and/or /dev/mshv presence. In order to make chxml2xmltest work regardless of host configuration, introduce a mock that pretends both of these files are accessible. Fixes: 51c14df9670ba2f5d193b700f39e6464e1bc18c6 Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- tests/chxml2xmlmock.c | 33 +++++++++++++++++++++++++++++++++ tests/chxml2xmltest.c | 2 +- tests/meson.build | 3 +++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 tests/chxml2xmlmock.c diff --git a/tests/chxml2xmlmock.c b/tests/chxml2xmlmock.c new file mode 100644 index 0000000000..73b210f35e --- /dev/null +++ b/tests/chxml2xmlmock.c @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2024 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include +#include + +#include "internal.h" +#include "virfile.h" + +bool +virFileExists(const char *path) +{ + if (STREQ(path, "/dev/kvm")) + return true; + if (STREQ(path, "/dev/mshv")) + return true; + return access(path, F_OK) =3D=3D 0; +} diff --git a/tests/chxml2xmltest.c b/tests/chxml2xmltest.c index 97b485dc4a..a5a75a1505 100644 --- a/tests/chxml2xmltest.c +++ b/tests/chxml2xmltest.c @@ -74,4 +74,4 @@ mymain(void) return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 -VIR_TEST_MAIN(mymain) +VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("chxml2xml")) diff --git a/tests/meson.build b/tests/meson.build index 4fc00e27da..3fcfa6b1e0 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -350,6 +350,9 @@ if conf.has('WITH_CH') tests +=3D [ { 'name': 'chxml2xmltest', 'link_with': [ ch_driver_impl ] }, ] + mock_libs +=3D [ + { 'name': 'chxml2xmlmock' }, + ] endif =20 if conf.has('WITH_ESX') --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org