Skip to content

Commit

Permalink
tests: Add network filter tests to the check-qtest-s390x list
Browse files Browse the repository at this point in the history
With some small modifications, we can also use the the netfilter,
the filter-mirror and the filter-redirector tests on s390x.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Message-Id: <1502951113-4246-3-git-send-email-thuth@redhat.com>
Reviewed-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
  • Loading branch information
huth authored and cohuck committed Aug 30, 2017
1 parent 7f57d58 commit ea5bef4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
3 changes: 3 additions & 0 deletions tests/Makefile.include
Expand Up @@ -361,6 +361,9 @@ check-qtest-xtensaeb-y = $(check-qtest-xtensa-y)

check-qtest-s390x-y = tests/boot-serial-test$(EXESUF)
check-qtest-s390x-$(CONFIG_SLIRP) += tests/pxe-test$(EXESUF)
check-qtest-s390x-$(CONFIG_SLIRP) += tests/test-netfilter$(EXESUF)
check-qtest-s390x-$(CONFIG_POSIX) += tests/test-filter-mirror$(EXESUF)
check-qtest-s390x-$(CONFIG_POSIX) += tests/test-filter-redirector$(EXESUF)

check-qtest-generic-y += tests/qom-test$(EXESUF)
check-qtest-generic-y += tests/test-hmp$(EXESUF)
Expand Down
9 changes: 7 additions & 2 deletions tests/test-filter-mirror.c
Expand Up @@ -25,6 +25,11 @@ static void test_mirror(void)
char *recv_buf;
uint32_t size = sizeof(send_buf);
size = htonl(size);
const char *devstr = "e1000";

if (g_str_equal(qtest_get_arch(), "s390x")) {
devstr = "virtio-net-ccw";
}

ret = socketpair(PF_UNIX, SOCK_STREAM, 0, send_sock);
g_assert_cmpint(ret, !=, -1);
Expand All @@ -33,10 +38,10 @@ static void test_mirror(void)
g_assert_cmpint(ret, !=, -1);

cmdline = g_strdup_printf("-netdev socket,id=qtest-bn0,fd=%d "
"-device e1000,netdev=qtest-bn0,id=qtest-e0 "
"-device %s,netdev=qtest-bn0,id=qtest-e0 "
"-chardev socket,id=mirror0,path=%s,server,nowait "
"-object filter-mirror,id=qtest-f0,netdev=qtest-bn0,queue=tx,outdev=mirror0 "
, send_sock[1], sock_path);
, send_sock[1], devstr, sock_path);
qtest_start(cmdline);
g_free(cmdline);

Expand Down
22 changes: 16 additions & 6 deletions tests/test-filter-redirector.c
Expand Up @@ -57,6 +57,16 @@
#include "qemu/error-report.h"
#include "qemu/main-loop.h"

static const char *get_devstr(void)
{
if (g_str_equal(qtest_get_arch(), "s390x")) {
return "virtio-net-ccw";
}

return "rtl8139";
}


static void test_redirector_tx(void)
{
int backend_sock[2], recv_sock;
Expand All @@ -78,7 +88,7 @@ static void test_redirector_tx(void)
g_assert_cmpint(ret, !=, -1);

cmdline = g_strdup_printf("-netdev socket,id=qtest-bn0,fd=%d "
"-device rtl8139,netdev=qtest-bn0,id=qtest-e0 "
"-device %s,netdev=qtest-bn0,id=qtest-e0 "
"-chardev socket,id=redirector0,path=%s,server,nowait "
"-chardev socket,id=redirector1,path=%s,server,nowait "
"-chardev socket,id=redirector2,path=%s,nowait "
Expand All @@ -87,8 +97,8 @@ static void test_redirector_tx(void)
"-object filter-redirector,id=qtest-f1,netdev=qtest-bn0,"
"queue=tx,indev=redirector2 "
"-object filter-redirector,id=qtest-f2,netdev=qtest-bn0,"
"queue=tx,outdev=redirector1 "
, backend_sock[1], sock_path0, sock_path1, sock_path0);
"queue=tx,outdev=redirector1 ", backend_sock[1], get_devstr(),
sock_path0, sock_path1, sock_path0);
qtest_start(cmdline);
g_free(cmdline);

Expand Down Expand Up @@ -149,7 +159,7 @@ static void test_redirector_rx(void)
g_assert_cmpint(ret, !=, -1);

cmdline = g_strdup_printf("-netdev socket,id=qtest-bn0,fd=%d "
"-device rtl8139,netdev=qtest-bn0,id=qtest-e0 "
"-device %s,netdev=qtest-bn0,id=qtest-e0 "
"-chardev socket,id=redirector0,path=%s,server,nowait "
"-chardev socket,id=redirector1,path=%s,server,nowait "
"-chardev socket,id=redirector2,path=%s,nowait "
Expand All @@ -158,8 +168,8 @@ static void test_redirector_rx(void)
"-object filter-redirector,id=qtest-f1,netdev=qtest-bn0,"
"queue=rx,outdev=redirector2 "
"-object filter-redirector,id=qtest-f2,netdev=qtest-bn0,"
"queue=rx,indev=redirector1 "
, backend_sock[1], sock_path0, sock_path1, sock_path0);
"queue=rx,indev=redirector1 ", backend_sock[1], get_devstr(),
sock_path0, sock_path1, sock_path0);
qtest_start(cmdline);
g_free(cmdline);

Expand Down
11 changes: 10 additions & 1 deletion tests/test-netfilter.c
Expand Up @@ -182,6 +182,12 @@ static void remove_netdev_with_multi_netfilter(void)
int main(int argc, char **argv)
{
int ret;
char *args;
const char *devstr = "e1000";

if (g_str_equal(qtest_get_arch(), "s390x")) {
devstr = "virtio-net-ccw";
}

g_test_init(&argc, &argv, NULL);
qtest_add_func("/netfilter/addremove_one", add_one_netfilter);
Expand All @@ -191,10 +197,13 @@ int main(int argc, char **argv)
qtest_add_func("/netfilter/remove_netdev_multi",
remove_netdev_with_multi_netfilter);

qtest_start("-netdev user,id=qtest-bn0 -device e1000,netdev=qtest-bn0");
args = g_strdup_printf("-netdev user,id=qtest-bn0 "
"-device %s,netdev=qtest-bn0", devstr);
qtest_start(args);
ret = g_test_run();

qtest_end();
g_free(args);

return ret;
}

0 comments on commit ea5bef4

Please sign in to comment.