]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: skip virfirewalltest on non-Linux systems
authorRoman Bogorodskiy <bogorodskiy@gmail.com>
Thu, 1 May 2014 18:43:58 +0000 (22:43 +0400)
committerRoman Bogorodskiy <bogorodskiy@gmail.com>
Fri, 2 May 2014 12:19:34 +0000 (16:19 +0400)
Currently firewalling is supported on Linux only, so skip the
virfirewalltest on other platforms.

tests/virfirewalltest.c

index 805fa44b7323129ca347e13d1e48e19178c2c49a..ba2e6ad4c9fe8bd78fd59374aab956dceaff46ca 100644 (file)
 #define __VIR_COMMAND_PRIV_H_ALLOW__
 
 #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 <dbus/dbus.h>
-#endif
+# include "virbuffer.h"
+# include "vircommandpriv.h"
+# 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 virBufferPtr fwBuf;
 static bool fwError;
 
-#define TEST_FILTER_TABLE_LIST                                  \
+# define TEST_FILTER_TABLE_LIST                                 \
     "Chain INPUT (policy ACCEPT)\n"                             \
     "target     prot opt source               destination\n"    \
     "\n"                                                        \
@@ -50,7 +53,7 @@ static bool fwError;
     "Chain OUTPUT (policy ACCEPT)\n"                            \
     "target     prot opt source               destination\n"
 
-#define TEST_NAT_TABLE_LIST                                             \
+# define TEST_NAT_TABLE_LIST                                            \
     "Chain PREROUTING (policy ACCEPT)\n"                                \
     "target     prot opt source               destination\n"            \
     "\n"                                                                \
@@ -63,7 +66,7 @@ static bool fwError;
     "Chain POSTROUTING (policy ACCEPT)\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,
                        DBusMessage *,
                        DBusConnection *, connection,
@@ -186,7 +189,7 @@ VIR_MOCK_IMPL_RET_ARGS(dbus_connection_send_with_reply_and_block,
 
     goto cleanup;
 }
-#endif
+# endif
 
 struct testFirewallData {
     virFirewallBackend tryBackend;
@@ -1126,7 +1129,7 @@ mymain(void)
 {
     int ret = 0;
 
-#define RUN_TEST_DIRECT(name, method)                                   \
+# define RUN_TEST_DIRECT(name, method)                                  \
     do {                                                                \
         struct testFirewallData data;                                   \
         data.tryBackend = VIR_FIREWALL_BACKEND_AUTOMATIC;               \
@@ -1141,8 +1144,8 @@ mymain(void)
             ret = -1;                                                   \
     } while (0)
 
-#if WITH_DBUS
-# define RUN_TEST_FIREWALLD(name, method)                               \
+# if WITH_DBUS
+#  define RUN_TEST_FIREWALLD(name, method)                              \
     do {                                                                \
         struct testFirewallData data;                                   \
         data.tryBackend = VIR_FIREWALL_BACKEND_AUTOMATIC;               \
@@ -1157,13 +1160,13 @@ mymain(void)
             ret = -1;                                                   \
     } while (0)
 
-# define RUN_TEST(name, method)                 \
+#  define RUN_TEST(name, method)                \
     RUN_TEST_DIRECT(name, method);              \
     RUN_TEST_FIREWALLD(name, method)
-#else /* ! WITH_DBUS */
-# define RUN_TEST(name, method)                 \
+# else /* ! WITH_DBUS */
+#  define RUN_TEST(name, method)                \
     RUN_TEST_DIRECT(name, method)
-#endif /* ! WITH_DBUS */
+# endif /* ! WITH_DBUS */
 
     RUN_TEST("single group", testFirewallSingleGroup);
     RUN_TEST("remove rule", testFirewallRemoveRule);
@@ -1179,8 +1182,17 @@ mymain(void)
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
-#if WITH_DBUS
+# if WITH_DBUS
 VIRT_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/virmockdbus.so")
-#else
+# else
 VIRT_TEST_MAIN(mymain)
-#endif
+# endif
+
+#else /* ! defined (__linux__) */
+
+int main(void)
+{
+    return EXIT_AM_SKIP;
+}
+
+#endif /* ! defined(__linux__) */