From nobody Sat Feb 7 06:20:55 2026 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=1618852582; cv=none; d=zohomail.com; s=zohoarc; b=eF/OOJH5h4YSq3vbTH5nkNEA8Z3vNgu1GvMKWKFw84GvmQgbCkMi6SJRD17bYGbKr2LAXEgoB4fFD3aCmWtR5bYdN5gN3LKe1dKF8qYuksOjmHT2EdP6MTn4GelbmbWof06GVBEXgoc4hmKntdFA+gLaIjTOd4hMs0RwiiRT19g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618852582; 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=IPoNNhEP/15r6R+H7A8loHF6wtj/hNd1taoFlSQtMDo=; b=klKWj3BwXMiNN+tbsvwS177nuh0gOIBM2VPQqEUUrUQ/uEsWMhVNSVy1E3eLSBEKO2kTh6mQJpS2RdOCwaR3ZPUc/svRizirqnaxJB2mbaQDiIJJHOIFcTVKopdN5Gaj7iZnhzEOXXL6tvhGUSkTXqiltJfvMhk/D/fhUlj7gH4= 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) header.from= 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 1618852582155385.28951587794506; Mon, 19 Apr 2021 10:16:22 -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-224-TfNcKHNvNGehvEHhKWv9uA-1; Mon, 19 Apr 2021 13:14:57 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5BC9C107ACF8; Mon, 19 Apr 2021 17:14:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 35C5810013D7; Mon, 19 Apr 2021 17:14:50 +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 01BE91806D20; Mon, 19 Apr 2021 17:14:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13JHEd8b021864 for ; Mon, 19 Apr 2021 13:14:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 058E55D742; Mon, 19 Apr 2021 17:14:39 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.40.195.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77F5D5D72E for ; Mon, 19 Apr 2021 17:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618852579; 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=IPoNNhEP/15r6R+H7A8loHF6wtj/hNd1taoFlSQtMDo=; b=RxF19CfSxDDLj/hk+erQPvETy4CZTnYaY7TCf0b5ce8u4mC2c2CkXgHFjKbcRly2QBjcNn Duw8LFSHRIMpsQk07WBW/mka9xQVTLueNZLWT2WBhvptDQM++rcLjPBFYC1Azdt9A97Wvd 7eKZ+rq0qXlpk4UYAv5hzdIyO23AsOQ= X-MC-Unique: TfNcKHNvNGehvEHhKWv9uA-1 From: Pavel Hrdina To: libvir-list@redhat.com Subject: [libvirt PATCH v2 08/21] tests: use virfirewallmock instead of hasNetfilterTools Date: Mon, 19 Apr 2021 19:14:11 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.22 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" Instead of checking for specific error that the binaries are not available mock the virFindFileInPath function. This way we don't have to skip these tests on host where the binaries are missing. Signed-off-by: Pavel Hrdina Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/networkxml2firewalltest.c | 16 ++-------------- tests/nwfilterebiptablestest.c | 15 +-------------- tests/nwfilterxml2firewalltest.c | 14 +------------- tests/virfirewalltest.c | 15 ++------------- 4 files changed, 6 insertions(+), 54 deletions(-) diff --git a/tests/networkxml2firewalltest.c b/tests/networkxml2firewalltes= t.c index 80ba510d14..91336a0c55 100644 --- a/tests/networkxml2firewalltest.c +++ b/tests/networkxml2firewalltest.c @@ -152,14 +152,6 @@ testCompareXMLToIPTablesHelper(const void *data) return result; } =20 -static bool -hasNetfilterTools(void) -{ - return virFileIsExecutable(IPTABLES_PATH) && - virFileIsExecutable(IP6TABLES_PATH) && - virFileIsExecutable(EBTABLES_PATH); -} - =20 static int mymain(void) @@ -179,11 +171,6 @@ mymain(void) } while (0) =20 if (virFirewallSetBackend(VIR_FIREWALL_BACKEND_DIRECT) < 0) { - if (!hasNetfilterTools()) { - fprintf(stderr, "iptables/ip6tables/ebtables tools not present= "); - return EXIT_AM_SKIP; - } - return EXIT_FAILURE; } =20 @@ -203,7 +190,8 @@ mymain(void) return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 -VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("virgdbus")) +VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("virgdbus"), + VIR_TEST_MOCK("virfirewall")) =20 #else /* ! defined (__linux__) */ =20 diff --git a/tests/nwfilterebiptablestest.c b/tests/nwfilterebiptablestest.c index 5f504cbe64..65b63959fb 100644 --- a/tests/nwfilterebiptablestest.c +++ b/tests/nwfilterebiptablestest.c @@ -482,14 +482,6 @@ testNWFilterEBIPTablesApplyDropAllRules(const void *op= aque G_GNUC_UNUSED) return ret; } =20 -static bool -hasNetfilterTools(void) -{ - return virFileIsExecutable(IPTABLES_PATH) && - virFileIsExecutable(IP6TABLES_PATH) && - virFileIsExecutable(EBTABLES_PATH); -} - =20 static int mymain(void) @@ -497,11 +489,6 @@ mymain(void) int ret =3D 0; =20 if (virFirewallSetBackend(VIR_FIREWALL_BACKEND_DIRECT) < 0) { - if (!hasNetfilterTools()) { - fprintf(stderr, "iptables/ip6tables/ebtables tools not present= "); - return EXIT_AM_SKIP; - } - return EXIT_FAILURE; } =20 @@ -543,4 +530,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("virfirewall")) diff --git a/tests/nwfilterxml2firewalltest.c b/tests/nwfilterxml2firewallt= est.c index 560372b802..6709cc15fd 100644 --- a/tests/nwfilterxml2firewalltest.c +++ b/tests/nwfilterxml2firewalltest.c @@ -431,14 +431,6 @@ testCompareXMLToIPTablesHelper(const void *data) return result; } =20 -static bool -hasNetfilterTools(void) -{ - return virFileIsExecutable(IPTABLES_PATH) && - virFileIsExecutable(IP6TABLES_PATH) && - virFileIsExecutable(EBTABLES_PATH); -} - =20 static int mymain(void) @@ -456,10 +448,6 @@ mymain(void) } while (0) =20 if (virFirewallSetBackend(VIR_FIREWALL_BACKEND_DIRECT) < 0) { - if (!hasNetfilterTools()) { - fprintf(stderr, "iptables/ip6tables/ebtables tools not present= "); - return EXIT_AM_SKIP; - } return EXIT_FAILURE; } =20 @@ -506,7 +494,7 @@ mymain(void) return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 -VIR_TEST_MAIN(mymain) +VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("virfirewall")) =20 #else /* ! defined (__linux__) */ =20 diff --git a/tests/virfirewalltest.c b/tests/virfirewalltest.c index 8e65fa8524..ac039f3bbf 100644 --- a/tests/virfirewalltest.c +++ b/tests/virfirewalltest.c @@ -1034,24 +1034,12 @@ testFirewallQuery(const void *opaque G_GNUC_UNUSED) return ret; } =20 -static bool -hasNetfilterTools(void) -{ - return virFileIsExecutable(IPTABLES_PATH) && - virFileIsExecutable(IP6TABLES_PATH) && - virFileIsExecutable(EBTABLES_PATH); -} =20 static int mymain(void) { int ret =3D 0; =20 - if (!hasNetfilterTools()) { - fprintf(stderr, "iptables/ip6tables/ebtables tools not present"); - return EXIT_AM_SKIP; - } - # define RUN_TEST_DIRECT(name, method) \ do { \ struct testFirewallData data; \ @@ -1100,7 +1088,8 @@ mymain(void) return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 -VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("virgdbus")) +VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("virgdbus"), + VIR_TEST_MOCK("virfirewall")) =20 #else /* ! defined (__linux__) */ =20 --=20 2.30.2