summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.include12
-rw-r--r--tests/boot-sector.c61
-rw-r--r--tests/pxe-test.c7
-rw-r--r--tests/test-filter-mirror.c14
-rw-r--r--tests/test-filter-redirector.c32
-rw-r--r--tests/test-netfilter.c11
6 files changed, 94 insertions, 43 deletions
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 37c1bed683..f08b7418f0 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)
@@ -360,6 +360,10 @@ check-qtest-microblazeel-y = $(check-qtest-microblaze-y)
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)
diff --git a/tests/boot-sector.c b/tests/boot-sector.c
index e3880f4455..9ee85370b0 100644
--- a/tests/boot-sector.c
+++ b/tests/boot-sector.c
@@ -21,13 +21,12 @@
#define SIGNATURE 0xdead
#define SIGNATURE_OFFSET 0x10
#define BOOT_SECTOR_ADDRESS 0x7c00
+#define SIGNATURE_ADDR (BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET)
-/* Boot sector code: write SIGNATURE into memory,
+/* x86 boot sector code: write SIGNATURE into memory,
* then halt.
- * Q35 machine requires a minimum 0x7e000 bytes disk.
- * (bug or feature?)
*/
-static uint8_t boot_sector[0x7e000] = {
+static uint8_t x86_boot_sector[512] = {
/* The first sector will be placed at RAM address 00007C00, and
* the BIOS transfers control to 00007C00
*/
@@ -50,8 +49,8 @@ static uint8_t boot_sector[0x7e000] = {
[0x07] = HIGH(SIGNATURE),
/* 7c08: mov %ax,0x7c10 */
[0x08] = 0xa3,
- [0x09] = LOW(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET),
- [0x0a] = HIGH(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET),
+ [0x09] = LOW(SIGNATURE_ADDR),
+ [0x0a] = HIGH(SIGNATURE_ADDR),
/* 7c0b cli */
[0x0b] = 0xfa,
@@ -68,11 +67,28 @@ static uint8_t boot_sector[0x7e000] = {
[0x1FF] = 0xAA,
};
+/* For s390x, use a mini "kernel" with the appropriate signature */
+static const uint8_t s390x_psw[] = {
+ 0x00, 0x08, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00
+};
+static const uint8_t s390x_code[] = {
+ 0xa7, 0xf4, 0x00, 0x0a, /* j 0x10010 */
+ 0x00, 0x00, 0x00, 0x00,
+ 'S', '3', '9', '0',
+ 'E', 'P', 0x00, 0x01,
+ 0xa7, 0x38, HIGH(SIGNATURE_ADDR), LOW(SIGNATURE_ADDR), /* lhi r3,0x7c10 */
+ 0xa7, 0x48, LOW(SIGNATURE), HIGH(SIGNATURE), /* lhi r4,0xadde */
+ 0x40, 0x40, 0x30, 0x00, /* sth r4,0(r3) */
+ 0xa7, 0xf4, 0xff, 0xfa /* j 0x10010 */
+};
+
/* Create boot disk file. */
int boot_sector_init(char *fname)
{
int fd, ret;
- size_t len = sizeof boot_sector;
+ size_t len;
+ char *boot_code;
+ const char *arch = qtest_get_arch();
fd = mkstemp(fname);
if (fd < 0) {
@@ -80,16 +96,31 @@ int boot_sector_init(char *fname)
return 1;
}
- /* For Open Firmware based system, we can use a Forth script instead */
- if (strcmp(qtest_get_arch(), "ppc64") == 0) {
- len = sprintf((char *)boot_sector, "\\ Bootscript\n%x %x c! %x %x c!\n",
- LOW(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET,
- HIGH(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);
+ if (g_str_equal(arch, "i386") || g_str_equal(arch, "x86_64")) {
+ /* Q35 requires a minimum 0x7e000 bytes disk (bug or feature?) */
+ len = MAX(0x7e000, sizeof(x86_boot_sector));
+ boot_code = g_malloc0(len);
+ memcpy(boot_code, x86_boot_sector, sizeof(x86_boot_sector));
+ } else if (g_str_equal(arch, "ppc64")) {
+ /* For Open Firmware based system, use a Forth script */
+ boot_code = g_strdup_printf("\\ Bootscript\n%x %x c! %x %x c!\n",
+ LOW(SIGNATURE), SIGNATURE_ADDR,
+ HIGH(SIGNATURE), SIGNATURE_ADDR + 1);
+ len = strlen(boot_code);
+ } else if (g_str_equal(arch, "s390x")) {
+ len = 0x10000 + sizeof(s390x_code);
+ boot_code = g_malloc0(len);
+ memcpy(boot_code, s390x_psw, sizeof(s390x_psw));
+ memcpy(&boot_code[0x10000], s390x_code, sizeof(s390x_code));
+ } else {
+ g_assert_not_reached();
}
- ret = write(fd, boot_sector, len);
+ ret = write(fd, boot_code, len);
close(fd);
+ g_free(boot_code);
+
if (ret != len) {
fprintf(stderr, "Could not write \"%s\"", fname);
return 1;
@@ -115,8 +146,8 @@ void boot_sector_test(void)
* instruction.
*/
for (i = 0; i < TEST_CYCLES; ++i) {
- signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET);
- signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);
+ signature_low = readb(SIGNATURE_ADDR);
+ signature_high = readb(SIGNATURE_ADDR + 1);
signature = (signature_high << 8) | signature_low;
if (signature == SIGNATURE) {
break;
diff --git a/tests/pxe-test.c b/tests/pxe-test.c
index cf6e225330..0d70afccd6 100644
--- a/tests/pxe-test.c
+++ b/tests/pxe-test.c
@@ -51,6 +51,11 @@ static void test_pxe_spapr_vlan(void)
test_pxe_one("-device spapr-vlan,netdev=" NETNAME, true);
}
+static void test_pxe_virtio_ccw(void)
+{
+ test_pxe_one("-device virtio-net-ccw,bootindex=1,netdev=" NETNAME, false);
+}
+
int main(int argc, char *argv[])
{
int ret;
@@ -68,6 +73,8 @@ int main(int argc, char *argv[])
} else if (strcmp(arch, "ppc64") == 0) {
qtest_add_func("pxe/virtio", test_pxe_virtio_pci);
qtest_add_func("pxe/spapr-vlan", test_pxe_spapr_vlan);
+ } else if (g_str_equal(arch, "s390x")) {
+ qtest_add_func("pxe/virtio-ccw", test_pxe_virtio_ccw);
}
ret = g_test_run();
boot_sector_cleanup(disk);
diff --git a/tests/test-filter-mirror.c b/tests/test-filter-mirror.c
index 9f84402493..d569d27657 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;
@@ -28,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);
@@ -36,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);
@@ -74,8 +76,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 0c4b8d52ef..3afd41110d 100644
--- a/tests/test-filter-redirector.c
+++ b/tests/test-filter-redirector.c
@@ -57,11 +57,18 @@
#include "qemu/error-report.h"
#include "qemu/main-loop.h"
-static void test_redirector_tx(void)
+static const char *get_devstr(void)
{
-#ifndef _WIN32
-/* socketpair(PF_UNIX) which does not exist on windows */
+ 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;
char *cmdline;
uint32_t ret = 0, len = 0;
@@ -81,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 "
@@ -90,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);
@@ -129,15 +136,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;
@@ -157,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 "
@@ -166,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);
@@ -203,8 +205,6 @@ static void test_redirector_rx(void)
unlink(sock_path0);
unlink(sock_path1);
qtest_end();
-
-#endif
}
int main(int argc, char **argv)
diff --git a/tests/test-netfilter.c b/tests/test-netfilter.c
index 8b5a9b21b5..2506473365 100644
--- a/tests/test-netfilter.c
+++ b/tests/test-netfilter.c
@@ -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);
@@ -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;
}