mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-08 12:41:29 +00:00
tests: skip virfirewalltest on non-Linux systems
Currently firewalling is supported on Linux only, so skip the virfirewalltest on other platforms.
This commit is contained in:
parent
f1856eb622
commit
064f49a050
@ -24,23 +24,26 @@
|
|||||||
#define __VIR_COMMAND_PRIV_H_ALLOW__
|
#define __VIR_COMMAND_PRIV_H_ALLOW__
|
||||||
|
|
||||||
#include "testutils.h"
|
#include "testutils.h"
|
||||||
#include "virbuffer.h"
|
|
||||||
#include "vircommandpriv.h"
|
|
||||||
#include "virfirewallpriv.h"
|
|
||||||
#include "virmock.h"
|
|
||||||
#include "virdbuspriv.h"
|
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_FIREWALL
|
#if defined(__linux__)
|
||||||
|
|
||||||
#if WITH_DBUS
|
# include "virbuffer.h"
|
||||||
# include <dbus/dbus.h>
|
# include "vircommandpriv.h"
|
||||||
#endif
|
# include "virfirewallpriv.h"
|
||||||
|
# include "virmock.h"
|
||||||
|
# include "virdbuspriv.h"
|
||||||
|
|
||||||
|
# define VIR_FROM_THIS VIR_FROM_FIREWALL
|
||||||
|
|
||||||
|
# if WITH_DBUS
|
||||||
|
# include <dbus/dbus.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
static bool fwDisabled = true;
|
static bool fwDisabled = true;
|
||||||
static virBufferPtr fwBuf;
|
static virBufferPtr fwBuf;
|
||||||
static bool fwError;
|
static bool fwError;
|
||||||
|
|
||||||
#define TEST_FILTER_TABLE_LIST \
|
# define TEST_FILTER_TABLE_LIST \
|
||||||
"Chain INPUT (policy ACCEPT)\n" \
|
"Chain INPUT (policy ACCEPT)\n" \
|
||||||
"target prot opt source destination\n" \
|
"target prot opt source destination\n" \
|
||||||
"\n" \
|
"\n" \
|
||||||
@ -50,7 +53,7 @@ static bool fwError;
|
|||||||
"Chain OUTPUT (policy ACCEPT)\n" \
|
"Chain OUTPUT (policy ACCEPT)\n" \
|
||||||
"target prot opt source destination\n"
|
"target prot opt source destination\n"
|
||||||
|
|
||||||
#define TEST_NAT_TABLE_LIST \
|
# define TEST_NAT_TABLE_LIST \
|
||||||
"Chain PREROUTING (policy ACCEPT)\n" \
|
"Chain PREROUTING (policy ACCEPT)\n" \
|
||||||
"target prot opt source destination\n" \
|
"target prot opt source destination\n" \
|
||||||
"\n" \
|
"\n" \
|
||||||
@ -63,7 +66,7 @@ static bool fwError;
|
|||||||
"Chain POSTROUTING (policy ACCEPT)\n" \
|
"Chain POSTROUTING (policy ACCEPT)\n" \
|
||||||
"target prot opt source destination\n"
|
"target prot opt source destination\n"
|
||||||
|
|
||||||
#if WITH_DBUS
|
# if WITH_DBUS
|
||||||
VIR_MOCK_IMPL_RET_ARGS(dbus_connection_send_with_reply_and_block,
|
VIR_MOCK_IMPL_RET_ARGS(dbus_connection_send_with_reply_and_block,
|
||||||
DBusMessage *,
|
DBusMessage *,
|
||||||
DBusConnection *, connection,
|
DBusConnection *, connection,
|
||||||
@ -186,7 +189,7 @@ VIR_MOCK_IMPL_RET_ARGS(dbus_connection_send_with_reply_and_block,
|
|||||||
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
struct testFirewallData {
|
struct testFirewallData {
|
||||||
virFirewallBackend tryBackend;
|
virFirewallBackend tryBackend;
|
||||||
@ -1126,7 +1129,7 @@ mymain(void)
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
#define RUN_TEST_DIRECT(name, method) \
|
# define RUN_TEST_DIRECT(name, method) \
|
||||||
do { \
|
do { \
|
||||||
struct testFirewallData data; \
|
struct testFirewallData data; \
|
||||||
data.tryBackend = VIR_FIREWALL_BACKEND_AUTOMATIC; \
|
data.tryBackend = VIR_FIREWALL_BACKEND_AUTOMATIC; \
|
||||||
@ -1141,8 +1144,8 @@ mymain(void)
|
|||||||
ret = -1; \
|
ret = -1; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#if WITH_DBUS
|
# if WITH_DBUS
|
||||||
# define RUN_TEST_FIREWALLD(name, method) \
|
# define RUN_TEST_FIREWALLD(name, method) \
|
||||||
do { \
|
do { \
|
||||||
struct testFirewallData data; \
|
struct testFirewallData data; \
|
||||||
data.tryBackend = VIR_FIREWALL_BACKEND_AUTOMATIC; \
|
data.tryBackend = VIR_FIREWALL_BACKEND_AUTOMATIC; \
|
||||||
@ -1157,13 +1160,13 @@ mymain(void)
|
|||||||
ret = -1; \
|
ret = -1; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
# define RUN_TEST(name, method) \
|
# define RUN_TEST(name, method) \
|
||||||
RUN_TEST_DIRECT(name, method); \
|
RUN_TEST_DIRECT(name, method); \
|
||||||
RUN_TEST_FIREWALLD(name, method)
|
RUN_TEST_FIREWALLD(name, method)
|
||||||
#else /* ! WITH_DBUS */
|
# else /* ! WITH_DBUS */
|
||||||
# define RUN_TEST(name, method) \
|
# define RUN_TEST(name, method) \
|
||||||
RUN_TEST_DIRECT(name, method)
|
RUN_TEST_DIRECT(name, method)
|
||||||
#endif /* ! WITH_DBUS */
|
# endif /* ! WITH_DBUS */
|
||||||
|
|
||||||
RUN_TEST("single group", testFirewallSingleGroup);
|
RUN_TEST("single group", testFirewallSingleGroup);
|
||||||
RUN_TEST("remove rule", testFirewallRemoveRule);
|
RUN_TEST("remove rule", testFirewallRemoveRule);
|
||||||
@ -1179,8 +1182,17 @@ mymain(void)
|
|||||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if WITH_DBUS
|
# if WITH_DBUS
|
||||||
VIRT_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/virmockdbus.so")
|
VIRT_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/virmockdbus.so")
|
||||||
#else
|
# else
|
||||||
VIRT_TEST_MAIN(mymain)
|
VIRT_TEST_MAIN(mymain)
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
|
#else /* ! defined (__linux__) */
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
return EXIT_AM_SKIP;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* ! defined(__linux__) */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user