This way we can get rid of the ugly #ifdefs in the code which makes
it easier to extend later.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/Makefile.include | 8 ++++----
tests/test-filter-mirror.c | 5 -----
tests/test-filter-redirector.c | 10 ----------
3 files changed, 4 insertions(+), 19 deletions(-)
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 37c1bed..8d5991d 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -283,8 +283,8 @@ ifeq ($(CONFIG_VHOST_USER_NET_TEST_i386),)
check-qtest-x86_64-$(CONFIG_VHOST_USER_NET_TEST_x86_64) += tests/vhost-user-test$(EXESUF)
endif
check-qtest-i386-$(CONFIG_SLIRP) += tests/test-netfilter$(EXESUF)
-check-qtest-i386-y += tests/test-filter-mirror$(EXESUF)
-check-qtest-i386-y += tests/test-filter-redirector$(EXESUF)
+check-qtest-i386-$(CONFIG_POSIX) += tests/test-filter-mirror$(EXESUF)
+check-qtest-i386-$(CONFIG_POSIX) += tests/test-filter-redirector$(EXESUF)
check-qtest-i386-y += tests/postcopy-test$(EXESUF)
check-qtest-i386-y += tests/test-x86-cpuid-compat$(EXESUF)
check-qtest-i386-y += tests/numa-test$(EXESUF)
@@ -325,8 +325,8 @@ check-qtest-ppc64-y += tests/usb-hcd-xhci-test$(EXESUF)
gcov-files-ppc64-y += hw/usb/hcd-xhci.c
check-qtest-ppc64-y += $(check-qtest-virtio-y)
check-qtest-ppc64-$(CONFIG_SLIRP) += tests/test-netfilter$(EXESUF)
-check-qtest-ppc64-y += tests/test-filter-mirror$(EXESUF)
-check-qtest-ppc64-y += tests/test-filter-redirector$(EXESUF)
+check-qtest-ppc64-$(CONFIG_POSIX) += tests/test-filter-mirror$(EXESUF)
+check-qtest-ppc64-$(CONFIG_POSIX) += tests/test-filter-redirector$(EXESUF)
check-qtest-ppc64-y += tests/display-vga-test$(EXESUF)
check-qtest-ppc64-y += tests/numa-test$(EXESUF)
check-qtest-ppc64-$(CONFIG_IVSHMEM) += tests/ivshmem-test$(EXESUF)
diff --git a/tests/test-filter-mirror.c b/tests/test-filter-mirror.c
index 9f84402..a1d5865 100644
--- a/tests/test-filter-mirror.c
+++ b/tests/test-filter-mirror.c
@@ -17,9 +17,6 @@
static void test_mirror(void)
{
-#ifndef _WIN32
-/* socketpair(PF_UNIX) which does not exist on windows */
-
int send_sock[2], recv_sock;
char *cmdline;
uint32_t ret = 0, len = 0;
@@ -74,8 +71,6 @@ static void test_mirror(void)
g_free(recv_buf);
close(recv_sock);
unlink(sock_path);
-
-#endif
}
int main(int argc, char **argv)
diff --git a/tests/test-filter-redirector.c b/tests/test-filter-redirector.c
index 0c4b8d5..69c663b 100644
--- a/tests/test-filter-redirector.c
+++ b/tests/test-filter-redirector.c
@@ -59,9 +59,6 @@
static void test_redirector_tx(void)
{
-#ifndef _WIN32
-/* socketpair(PF_UNIX) which does not exist on windows */
-
int backend_sock[2], recv_sock;
char *cmdline;
uint32_t ret = 0, len = 0;
@@ -129,15 +126,10 @@ static void test_redirector_tx(void)
unlink(sock_path0);
unlink(sock_path1);
qtest_end();
-
-#endif
}
static void test_redirector_rx(void)
{
-#ifndef _WIN32
-/* socketpair(PF_UNIX) which does not exist on windows */
-
int backend_sock[2], send_sock;
char *cmdline;
uint32_t ret = 0, len = 0;
@@ -203,8 +195,6 @@ static void test_redirector_rx(void)
unlink(sock_path0);
unlink(sock_path1);
qtest_end();
-
-#endif
}
int main(int argc, char **argv)
--
1.8.3.1
On Thu, 17 Aug 2017 08:25:08 +0200 Thomas Huth <thuth@redhat.com> wrote: > This way we can get rid of the ugly #ifdefs in the code which makes > it easier to extend later. > > Signed-off-by: Thomas Huth <thuth@redhat.com> > --- > tests/Makefile.include | 8 ++++---- > tests/test-filter-mirror.c | 5 ----- > tests/test-filter-redirector.c | 10 ---------- > 3 files changed, 4 insertions(+), 19 deletions(-) Yes, that is much nicer. Reviewed-by: Cornelia Huck <cohuck@redhat.com>
On 17.08.2017 08:25, Thomas Huth wrote: > This way we can get rid of the ugly #ifdefs in the code which makes > it easier to extend later. > > Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: David Hildenbrand <david@redhat.com> -- Thanks, David
On 08/17/2017 02:25 PM, Thomas Huth wrote: > This way we can get rid of the ugly #ifdefs in the code which makes > it easier to extend later. > > Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Zhang Chen<zhangchen.fnst@cn.fujitsu.com> It's better for my code. Thanks Zhang Chen > --- > tests/Makefile.include | 8 ++++---- > tests/test-filter-mirror.c | 5 ----- > tests/test-filter-redirector.c | 10 ---------- > 3 files changed, 4 insertions(+), 19 deletions(-) > -- Thanks Zhang Chen
On 08/17/2017 02:25 AM, Thomas Huth wrote:
> This way we can get rid of the ugly #ifdefs in the code which makes
> it easier to extend later.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
> tests/Makefile.include | 8 ++++----
> tests/test-filter-mirror.c | 5 -----
> tests/test-filter-redirector.c | 10 ----------
> 3 files changed, 4 insertions(+), 19 deletions(-)
>
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index 37c1bed..8d5991d 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -283,8 +283,8 @@ ifeq ($(CONFIG_VHOST_USER_NET_TEST_i386),)
> check-qtest-x86_64-$(CONFIG_VHOST_USER_NET_TEST_x86_64) += tests/vhost-user-test$(EXESUF)
> endif
> check-qtest-i386-$(CONFIG_SLIRP) += tests/test-netfilter$(EXESUF)
> -check-qtest-i386-y += tests/test-filter-mirror$(EXESUF)
> -check-qtest-i386-y += tests/test-filter-redirector$(EXESUF)
> +check-qtest-i386-$(CONFIG_POSIX) += tests/test-filter-mirror$(EXESUF)
> +check-qtest-i386-$(CONFIG_POSIX) += tests/test-filter-redirector$(EXESUF)
> check-qtest-i386-y += tests/postcopy-test$(EXESUF)
> check-qtest-i386-y += tests/test-x86-cpuid-compat$(EXESUF)
> check-qtest-i386-y += tests/numa-test$(EXESUF)
> @@ -325,8 +325,8 @@ check-qtest-ppc64-y += tests/usb-hcd-xhci-test$(EXESUF)
> gcov-files-ppc64-y += hw/usb/hcd-xhci.c
> check-qtest-ppc64-y += $(check-qtest-virtio-y)
> check-qtest-ppc64-$(CONFIG_SLIRP) += tests/test-netfilter$(EXESUF)
> -check-qtest-ppc64-y += tests/test-filter-mirror$(EXESUF)
> -check-qtest-ppc64-y += tests/test-filter-redirector$(EXESUF)
> +check-qtest-ppc64-$(CONFIG_POSIX) += tests/test-filter-mirror$(EXESUF)
> +check-qtest-ppc64-$(CONFIG_POSIX) += tests/test-filter-redirector$(EXESUF)
> check-qtest-ppc64-y += tests/display-vga-test$(EXESUF)
> check-qtest-ppc64-y += tests/numa-test$(EXESUF)
> check-qtest-ppc64-$(CONFIG_IVSHMEM) += tests/ivshmem-test$(EXESUF)
> diff --git a/tests/test-filter-mirror.c b/tests/test-filter-mirror.c
> index 9f84402..a1d5865 100644
> --- a/tests/test-filter-mirror.c
> +++ b/tests/test-filter-mirror.c
> @@ -17,9 +17,6 @@
>
> static void test_mirror(void)
> {
> -#ifndef _WIN32
> -/* socketpair(PF_UNIX) which does not exist on windows */
> -
> int send_sock[2], recv_sock;
> char *cmdline;
> uint32_t ret = 0, len = 0;
> @@ -74,8 +71,6 @@ static void test_mirror(void)
> g_free(recv_buf);
> close(recv_sock);
> unlink(sock_path);
> -
> -#endif
> }
>
> int main(int argc, char **argv)
> diff --git a/tests/test-filter-redirector.c b/tests/test-filter-redirector.c
> index 0c4b8d5..69c663b 100644
> --- a/tests/test-filter-redirector.c
> +++ b/tests/test-filter-redirector.c
> @@ -59,9 +59,6 @@
>
> static void test_redirector_tx(void)
> {
> -#ifndef _WIN32
> -/* socketpair(PF_UNIX) which does not exist on windows */
> -
> int backend_sock[2], recv_sock;
> char *cmdline;
> uint32_t ret = 0, len = 0;
> @@ -129,15 +126,10 @@ static void test_redirector_tx(void)
> unlink(sock_path0);
> unlink(sock_path1);
> qtest_end();
> -
> -#endif
> }
>
> static void test_redirector_rx(void)
> {
> -#ifndef _WIN32
> -/* socketpair(PF_UNIX) which does not exist on windows */
> -
> int backend_sock[2], send_sock;
> char *cmdline;
> uint32_t ret = 0, len = 0;
> @@ -203,8 +195,6 @@ static void test_redirector_rx(void)
> unlink(sock_path0);
> unlink(sock_path1);
> qtest_end();
> -
> -#endif
> }
>
> int main(int argc, char **argv)
>
Tested attempting to cross-compile those:
$ ./configure --cross-prefix=i686-w64-mingw32-
$ make
$ make tests/test-filter-mirror.exe
...
CC tests/test-filter-redirector.o
tests/test-filter-redirector.c: In function 'test_redirector_tx':
tests/test-filter-redirector.c:72:11: error: implicit declaration of
function 'socketpair'; did you mean 'socket_init'?
[-Werror=implicit-function-declaration]
...
Which is supposed to fail.
Tested-by: Cleber Rosa <crosa@redhat.com>
© 2016 - 2026 Red Hat, Inc.