diff options
author | Andreas Färber <afaerber@suse.de> | 2015-10-11 00:18:32 +0200 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2015-10-24 18:02:48 +0200 |
commit | bbfc2efefe9779f85dfe2713aec1568b1ba871ad (patch) | |
tree | 2e4c7d46f5686ab265a1b8b9afe02bd5f83be8e0 /tests/ivshmem-test.c | |
parent | dd054be35fa355a6ebeab58618d7ff662247a9f6 (diff) | |
download | qemu-bbfc2efefe9779f85dfe2713aec1568b1ba871ad.zip qemu-bbfc2efefe9779f85dfe2713aec1568b1ba871ad.tar.gz qemu-bbfc2efefe9779f85dfe2713aec1568b1ba871ad.tar.bz2 |
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>
Diffstat (limited to 'tests/ivshmem-test.c')
-rw-r--r-- | tests/ivshmem-test.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/ivshmem-test.c b/tests/ivshmem-test.c new file mode 100644 index 0000000..2f6bec8 --- /dev/null +++ b/tests/ivshmem-test.c @@ -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; +} |