]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Prevent test failures with ebtables/iptables/ip6tables are missing
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 7 Apr 2017 14:11:14 +0000 (15:11 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 19 Apr 2017 09:51:51 +0000 (10:51 +0100)
When running tests in a restricted container (as opposed to a full
OS install), we can't assume ebtables/iptbles/ip6tables are going
to be installed. We must check this and mark the tests as skipped.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
tests/networkxml2firewalltest.c
tests/nwfilterebiptablestest.c
tests/nwfilterxml2firewalltest.c
tests/virfirewalltest.c

index 58a9516686c1d65e1373a59e77b6c99f94710cd4..fed0e663918d061a206a04f85bf6f7fd625b1515 100644 (file)
@@ -108,6 +108,14 @@ testCompareXMLToIPTablesHelper(const void *data)
     return result;
 }
 
+static bool
+hasNetfilterTools(void)
+{
+    return virFileIsExecutable(IPTABLES_PATH) &&
+        virFileIsExecutable(IP6TABLES_PATH) &&
+        virFileIsExecutable(EBTABLES_PATH);
+}
+
 
 static int
 mymain(void)
@@ -131,6 +139,11 @@ mymain(void)
     virFirewallSetLockOverride(true);
 
     if (virFirewallSetBackend(VIR_FIREWALL_BACKEND_DIRECT) < 0) {
+        if (!hasNetfilterTools()) {
+            fprintf(stderr, "iptables/ip6tables/ebtables tools not present");
+            return EXIT_AM_SKIP;
+        }
+
         ret = -1;
         goto cleanup;
     }
index 4357133783627db3d6c839b38d171bc61429dad0..607342330458ffc130ad86332399b759af37c1e3 100644 (file)
@@ -517,6 +517,14 @@ testNWFilterEBIPTablesApplyDropAllRules(const void *opaque ATTRIBUTE_UNUSED)
     return ret;
 }
 
+static bool
+hasNetfilterTools(void)
+{
+    return virFileIsExecutable(IPTABLES_PATH) &&
+        virFileIsExecutable(IP6TABLES_PATH) &&
+        virFileIsExecutable(EBTABLES_PATH);
+}
+
 
 static int
 mymain(void)
@@ -526,6 +534,11 @@ mymain(void)
     virFirewallSetLockOverride(true);
 
     if (virFirewallSetBackend(VIR_FIREWALL_BACKEND_DIRECT) < 0) {
+        if (!hasNetfilterTools()) {
+            fprintf(stderr, "iptables/ip6tables/ebtables tools not present");
+            return EXIT_AM_SKIP;
+        }
+
         ret = -1;
         goto cleanup;
     }
index 95ab46e22ec72bacbc4577c342bef2ba1c746144..3d6e792b707d0fbe88489aa40b3ed7009c99315f 100644 (file)
@@ -445,6 +445,14 @@ testCompareXMLToIPTablesHelper(const void *data)
     return result;
 }
 
+static bool
+hasNetfilterTools(void)
+{
+    return virFileIsExecutable(IPTABLES_PATH) &&
+        virFileIsExecutable(IP6TABLES_PATH) &&
+        virFileIsExecutable(EBTABLES_PATH);
+}
+
 
 static int
 mymain(void)
@@ -468,6 +476,10 @@ mymain(void)
     virFirewallSetLockOverride(true);
 
     if (virFirewallSetBackend(VIR_FIREWALL_BACKEND_DIRECT) < 0) {
+        if (!hasNetfilterTools()) {
+            fprintf(stderr, "iptables/ip6tables/ebtables tools not present");
+            return EXIT_AM_SKIP;
+        }
         ret = -1;
         goto cleanup;
     }
index 0f703a6bdc9b7f9723d1b2b9deabd2af5c926192..ac99b824378f8cddb2a6cc282f16514f23ad24e2 100644 (file)
@@ -1123,11 +1123,24 @@ testFirewallQuery(const void *opaque ATTRIBUTE_UNUSED)
     return ret;
 }
 
+static bool
+hasNetfilterTools(void)
+{
+    return virFileIsExecutable(IPTABLES_PATH) &&
+        virFileIsExecutable(IP6TABLES_PATH) &&
+        virFileIsExecutable(EBTABLES_PATH);
+}
+
 static int
 mymain(void)
 {
     int ret = 0;
 
+    if (!hasNetfilterTools()) {
+        fprintf(stderr, "iptables/ip6tables/ebtables tools not present");
+        return EXIT_AM_SKIP;
+    }
+
 # define RUN_TEST_DIRECT(name, method)                                  \
     do {                                                                \
         struct testFirewallData data;                                   \