]>
Commit | Line | Data |
---|---|---|
bbfc2efe AF |
1 | /* |
2 | * QTest testcase for ivshmem | |
3 | * | |
4 | * Copyright (c) 2014 SUSE LINUX Products GmbH | |
5 | * | |
6 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | |
7 | * See the COPYING file in the top-level directory. | |
8 | */ | |
9 | ||
10 | #include <glib.h> | |
11 | #include <stdlib.h> | |
12 | #include <string.h> | |
13 | #include <unistd.h> | |
14 | #include "libqtest.h" | |
15 | #include "qemu/osdep.h" | |
16 | ||
17 | static char dev_shm_path[] = "/dev/shm/qtest.XXXXXX"; | |
18 | ||
19 | /* Tests only initialization so far. TODO: Replace with functional tests */ | |
20 | static void nop(void) | |
21 | { | |
22 | } | |
23 | ||
24 | int main(int argc, char **argv) | |
25 | { | |
26 | QTestState *s1, *s2; | |
27 | char *cmd; | |
28 | int ret, fd; | |
29 | ||
30 | g_test_init(&argc, &argv, NULL); | |
31 | qtest_add_func("/ivshmem/nop", nop); | |
32 | ||
33 | fd = mkstemp(dev_shm_path); | |
34 | g_assert(fd >= 0); | |
35 | close(fd); | |
36 | unlink(dev_shm_path); | |
37 | ||
38 | cmd = g_strdup_printf("-device ivshmem,shm=%s,size=1M", &dev_shm_path[9]); | |
39 | s1 = qtest_start(cmd); | |
40 | s2 = qtest_start(cmd); | |
41 | g_free(cmd); | |
42 | ||
43 | ret = g_test_run(); | |
44 | ||
45 | qtest_quit(s1); | |
46 | qtest_quit(s2); | |
47 | ||
48 | unlink(dev_shm_path); | |
49 | ||
50 | return ret; | |
51 | } |