From nobody Sun Feb 8 23:37:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1600331510; cv=none; d=zohomail.com; s=zohoarc; b=ZDEY6iYSgdKnE3xilEXvuJIaiNuuzOaLbm5NaD4qeM2R0pXMIEBBRcN7GWw3A7jQZnG7beqZdoy6IdpxPJwM426rDJ6E6LHzmunE646z3hzXU8vNKoF7AowSObUFqtFPssfAMHWUmuoYhGdlKk+DZRc/IINVZiEF60K8OslMEcE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600331510; 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=kiOtE+L37SYeO8gKlaD91eoI0KvXo+WER6a8rKS5lw4=; b=l0sHOSGhk62DVU3Ovzhws1Kjddwp0LkPSS6Hq0I5HE6PI3IsWIugPpHI1oG9JcYY59CHr+AGkbC1U+dLup7vBywO63qGE7NiDPRp4exD+/unEYfk52cYll819o/D0penFdqIxrnfjXA/1mQKAYF5f1wxKoAx7bx4lO4hsSvH3WM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1600331510814697.8507408651496; Thu, 17 Sep 2020 01:31:50 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-51-xZeH-UehPNW7UXhPYm5Vrg-1; Thu, 17 Sep 2020 04:31:44 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ADEF9188C137; Thu, 17 Sep 2020 08:31:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 86EFC19728; Thu, 17 Sep 2020 08:31:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4D6DD44A7C; Thu, 17 Sep 2020 08:31:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08H8Tumt004064 for ; Thu, 17 Sep 2020 04:29:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id B97EC5DA30; Thu, 17 Sep 2020 08:29:56 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.195.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB0A65DEC4 for ; Thu, 17 Sep 2020 08:29:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600331506; 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=kiOtE+L37SYeO8gKlaD91eoI0KvXo+WER6a8rKS5lw4=; b=Ky4ewY83NQkcHtvLs7TOKf+oGluKNSTXAcgd3x9fTNgVSbACpohanlNnGlEIbVTMBMd+eP RYZGTpv/qYbMLe0KVqsWQ3cEp5gwHE+k+BUCTmEyLQW4+0nst8Jpr/pD9ZwjaD2YTthPed /r5py613a0EgXIoG/4ayvP5tzTotTZg= X-MC-Unique: xZeH-UehPNW7UXhPYm5Vrg-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH 02/14] tests: mock libdbus in networkxml2firewalltest Date: Thu, 17 Sep 2020 10:29:37 +0200 Message-Id: <99b42fda8046355e1b9f08c9bd14335ce9e300a3.1600331276.git.phrdina@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This test calls into src/util/virfirewalld.c where it uses DBus to figure out if firewalld is registered. Without the mock it luckily fails and the test works correctly. To isolate the tests from host environment we should mock the DBus calls. Signed-off-by: Pavel Hrdina --- tests/meson.build | 2 +- tests/networkxml2firewalltest.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/meson.build b/tests/meson.build index 0a204c46e4..f0f3d8c1ef 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -404,7 +404,7 @@ endif if conf.has('WITH_NETWORK') tests +=3D [ { 'name': 'networkxml2conftest', 'link_with': [ network_driver_impl ] = }, - { 'name': 'networkxml2firewalltest', 'link_with': [ network_driver_imp= l ] }, + { 'name': 'networkxml2firewalltest', 'link_with': [ network_driver_imp= l ], 'deps': [ dbus_dep ] }, { 'name': 'networkxml2xmltest', 'link_with': [ network_driver_impl ] }, ] endif diff --git a/tests/networkxml2firewalltest.c b/tests/networkxml2firewalltes= t.c index 29e7d8bc38..80e2d6a035 100644 --- a/tests/networkxml2firewalltest.c +++ b/tests/networkxml2firewalltest.c @@ -26,8 +26,13 @@ =20 #if defined (__linux__) =20 +# if WITH_DBUS +# include +# endif + # include "network/bridge_driver_platform.h" # include "virbuffer.h" +# include "virmock.h" =20 # define LIBVIRT_VIRFIREWALLPRIV_H_ALLOW # include "virfirewallpriv.h" @@ -43,6 +48,22 @@ # error "test case not ported to this platform" # endif =20 +# if WITH_DBUS +VIR_MOCK_WRAP_RET_ARGS(dbus_connection_send_with_reply_and_block, + DBusMessage *, + DBusConnection *, connection, + DBusMessage *, message, + int, timeout_milliseconds, + DBusError *, error) +{ + VIR_MOCK_REAL_INIT(dbus_connection_send_with_reply_and_block); + + dbus_set_error_const(error, "org.freedesktop.error", "dbus is disabled= "); + + return NULL; +} +# endif + static void testCommandDryRun(const char *const*args G_GNUC_UNUSED, const char *const*env G_GNUC_UNUSED, @@ -176,7 +197,11 @@ mymain(void) return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 +# if WITH_DBUS +VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("virdbus")) +# else VIR_TEST_MAIN(mymain) +# endif =20 #else /* ! defined (__linux__) */ =20 --=20 2.26.2