mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
tests: use virfirewallmock instead of hasNetfilterTools
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 <phrdina@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
e938ea5062
commit
50a021df33
@ -152,14 +152,6 @@ 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)
|
||||||
@ -179,11 +171,6 @@ mymain(void)
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +190,8 @@ mymain(void)
|
|||||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("virgdbus"))
|
VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("virgdbus"),
|
||||||
|
VIR_TEST_MOCK("virfirewall"))
|
||||||
|
|
||||||
#else /* ! defined (__linux__) */
|
#else /* ! defined (__linux__) */
|
||||||
|
|
||||||
|
@ -482,14 +482,6 @@ testNWFilterEBIPTablesApplyDropAllRules(const void *opaque G_GNUC_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)
|
||||||
@ -497,11 +489,6 @@ mymain(void)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -543,4 +530,4 @@ mymain(void)
|
|||||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_TEST_MAIN(mymain)
|
VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("virfirewall"))
|
||||||
|
@ -431,14 +431,6 @@ 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)
|
||||||
@ -456,10 +448,6 @@ mymain(void)
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,7 +494,7 @@ mymain(void)
|
|||||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_TEST_MAIN(mymain)
|
VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("virfirewall"))
|
||||||
|
|
||||||
#else /* ! defined (__linux__) */
|
#else /* ! defined (__linux__) */
|
||||||
|
|
||||||
|
@ -1034,24 +1034,12 @@ testFirewallQuery(const void *opaque G_GNUC_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; \
|
||||||
@ -1100,7 +1088,8 @@ mymain(void)
|
|||||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("virgdbus"))
|
VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("virgdbus"),
|
||||||
|
VIR_TEST_MOCK("virfirewall"))
|
||||||
|
|
||||||
#else /* ! defined (__linux__) */
|
#else /* ! defined (__linux__) */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user