mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
Prevent test failures with ebtables/iptables/ip6tables are missing
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>
This commit is contained in:
parent
728cacc8ab
commit
6f37cb80df
@ -108,6 +108,14 @@ testCompareXMLToIPTablesHelper(const void *data)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
hasNetfilterTools(void)
|
||||||
|
{
|
||||||
|
return virFileIsExecutable(IPTABLES_PATH) &&
|
||||||
|
virFileIsExecutable(IP6TABLES_PATH) &&
|
||||||
|
virFileIsExecutable(EBTABLES_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mymain(void)
|
mymain(void)
|
||||||
@ -131,6 +139,11 @@ mymain(void)
|
|||||||
virFirewallSetLockOverride(true);
|
virFirewallSetLockOverride(true);
|
||||||
|
|
||||||
if (virFirewallSetBackend(VIR_FIREWALL_BACKEND_DIRECT) < 0) {
|
if (virFirewallSetBackend(VIR_FIREWALL_BACKEND_DIRECT) < 0) {
|
||||||
|
if (!hasNetfilterTools()) {
|
||||||
|
fprintf(stderr, "iptables/ip6tables/ebtables tools not present");
|
||||||
|
return EXIT_AM_SKIP;
|
||||||
|
}
|
||||||
|
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -517,6 +517,14 @@ testNWFilterEBIPTablesApplyDropAllRules(const void *opaque ATTRIBUTE_UNUSED)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
hasNetfilterTools(void)
|
||||||
|
{
|
||||||
|
return virFileIsExecutable(IPTABLES_PATH) &&
|
||||||
|
virFileIsExecutable(IP6TABLES_PATH) &&
|
||||||
|
virFileIsExecutable(EBTABLES_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mymain(void)
|
mymain(void)
|
||||||
@ -526,6 +534,11 @@ mymain(void)
|
|||||||
virFirewallSetLockOverride(true);
|
virFirewallSetLockOverride(true);
|
||||||
|
|
||||||
if (virFirewallSetBackend(VIR_FIREWALL_BACKEND_DIRECT) < 0) {
|
if (virFirewallSetBackend(VIR_FIREWALL_BACKEND_DIRECT) < 0) {
|
||||||
|
if (!hasNetfilterTools()) {
|
||||||
|
fprintf(stderr, "iptables/ip6tables/ebtables tools not present");
|
||||||
|
return EXIT_AM_SKIP;
|
||||||
|
}
|
||||||
|
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -445,6 +445,14 @@ testCompareXMLToIPTablesHelper(const void *data)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
hasNetfilterTools(void)
|
||||||
|
{
|
||||||
|
return virFileIsExecutable(IPTABLES_PATH) &&
|
||||||
|
virFileIsExecutable(IP6TABLES_PATH) &&
|
||||||
|
virFileIsExecutable(EBTABLES_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mymain(void)
|
mymain(void)
|
||||||
@ -468,6 +476,10 @@ mymain(void)
|
|||||||
virFirewallSetLockOverride(true);
|
virFirewallSetLockOverride(true);
|
||||||
|
|
||||||
if (virFirewallSetBackend(VIR_FIREWALL_BACKEND_DIRECT) < 0) {
|
if (virFirewallSetBackend(VIR_FIREWALL_BACKEND_DIRECT) < 0) {
|
||||||
|
if (!hasNetfilterTools()) {
|
||||||
|
fprintf(stderr, "iptables/ip6tables/ebtables tools not present");
|
||||||
|
return EXIT_AM_SKIP;
|
||||||
|
}
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -1123,11 +1123,24 @@ testFirewallQuery(const void *opaque ATTRIBUTE_UNUSED)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
hasNetfilterTools(void)
|
||||||
|
{
|
||||||
|
return virFileIsExecutable(IPTABLES_PATH) &&
|
||||||
|
virFileIsExecutable(IP6TABLES_PATH) &&
|
||||||
|
virFileIsExecutable(EBTABLES_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mymain(void)
|
mymain(void)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
if (!hasNetfilterTools()) {
|
||||||
|
fprintf(stderr, "iptables/ip6tables/ebtables tools not present");
|
||||||
|
return EXIT_AM_SKIP;
|
||||||
|
}
|
||||||
|
|
||||||
# define RUN_TEST_DIRECT(name, method) \
|
# define RUN_TEST_DIRECT(name, method) \
|
||||||
do { \
|
do { \
|
||||||
struct testFirewallData data; \
|
struct testFirewallData data; \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user