tests: Add ivshmem qtest
Note that it launches two instances, as sharing memory is the purpose of ivshmem. Cc: Cam Macdonell <cam@cs.ualberta.ca> Cc: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de> [ Remove Nahanni codename, add test to pci set - Marc-André ] Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
dd054be35f
commit
bbfc2efefe
|
@ -150,6 +150,8 @@ gcov-files-pci-y += hw/display/virtio-gpu-pci.c
|
||||||
gcov-files-pci-$(CONFIG_VIRTIO_VGA) += hw/display/virtio-vga.c
|
gcov-files-pci-$(CONFIG_VIRTIO_VGA) += hw/display/virtio-vga.c
|
||||||
check-qtest-pci-y += tests/intel-hda-test$(EXESUF)
|
check-qtest-pci-y += tests/intel-hda-test$(EXESUF)
|
||||||
gcov-files-pci-y += hw/audio/intel-hda.c hw/audio/hda-codec.c
|
gcov-files-pci-y += hw/audio/intel-hda.c hw/audio/hda-codec.c
|
||||||
|
check-qtest-pci-$(CONFIG_POSIX) += tests/ivshmem-test$(EXESUF)
|
||||||
|
gcov-files-pci-y += hw/misc/ivshmem.c
|
||||||
|
|
||||||
check-qtest-i386-y = tests/endianness-test$(EXESUF)
|
check-qtest-i386-y = tests/endianness-test$(EXESUF)
|
||||||
check-qtest-i386-y += tests/fdc-test$(EXESUF)
|
check-qtest-i386-y += tests/fdc-test$(EXESUF)
|
||||||
|
@ -522,6 +524,7 @@ tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_hel
|
||||||
tests/test-qemu-opts$(EXESUF): tests/test-qemu-opts.o $(test-util-obj-y)
|
tests/test-qemu-opts$(EXESUF): tests/test-qemu-opts.o $(test-util-obj-y)
|
||||||
tests/test-write-threshold$(EXESUF): tests/test-write-threshold.o $(test-block-obj-y)
|
tests/test-write-threshold$(EXESUF): tests/test-write-threshold.o $(test-block-obj-y)
|
||||||
tests/test-netfilter$(EXESUF): tests/test-netfilter.o $(qtest-obj-y)
|
tests/test-netfilter$(EXESUF): tests/test-netfilter.o $(qtest-obj-y)
|
||||||
|
tests/ivshmem-test$(EXESUF): tests/ivshmem-test.o
|
||||||
|
|
||||||
ifeq ($(CONFIG_POSIX),y)
|
ifeq ($(CONFIG_POSIX),y)
|
||||||
LIBS += -lutil
|
LIBS += -lutil
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* QTest testcase for ivshmem
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014 SUSE LINUX Products GmbH
|
||||||
|
*
|
||||||
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||||
|
* See the COPYING file in the top-level directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "libqtest.h"
|
||||||
|
#include "qemu/osdep.h"
|
||||||
|
|
||||||
|
static char dev_shm_path[] = "/dev/shm/qtest.XXXXXX";
|
||||||
|
|
||||||
|
/* Tests only initialization so far. TODO: Replace with functional tests */
|
||||||
|
static void nop(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
QTestState *s1, *s2;
|
||||||
|
char *cmd;
|
||||||
|
int ret, fd;
|
||||||
|
|
||||||
|
g_test_init(&argc, &argv, NULL);
|
||||||
|
qtest_add_func("/ivshmem/nop", nop);
|
||||||
|
|
||||||
|
fd = mkstemp(dev_shm_path);
|
||||||
|
g_assert(fd >= 0);
|
||||||
|
close(fd);
|
||||||
|
unlink(dev_shm_path);
|
||||||
|
|
||||||
|
cmd = g_strdup_printf("-device ivshmem,shm=%s,size=1M", &dev_shm_path[9]);
|
||||||
|
s1 = qtest_start(cmd);
|
||||||
|
s2 = qtest_start(cmd);
|
||||||
|
g_free(cmd);
|
||||||
|
|
||||||
|
ret = g_test_run();
|
||||||
|
|
||||||
|
qtest_quit(s1);
|
||||||
|
qtest_quit(s2);
|
||||||
|
|
||||||
|
unlink(dev_shm_path);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
Loading…
Reference in New Issue