summaryrefslogtreecommitdiffstats
path: root/tests/ivshmem-test.c
blob: 2f6bec890247dae05254327cf2224ac7ee468d0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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;
}
OpenPOWER on IntegriCloud