Skip to content

Commit e019356

Browse files
elmarcomstsirkin
authored andcommitted
libvhost-user: add a simple link test without glib
Signed-off-by: Marc-André Lureau <[email protected]> Message-Id: <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 0df750e commit e019356

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

subprojects/libvhost-user/link-test.c

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* A trivial unit test to check linking without glib. A real test suite should
3+
* probably based off libvhost-user-glib instead.
4+
*/
5+
#include <assert.h>
6+
#include <stdlib.h>
7+
#include "libvhost-user.h"
8+
9+
static void
10+
panic(VuDev *dev, const char *err)
11+
{
12+
abort();
13+
}
14+
15+
static void
16+
set_watch(VuDev *dev, int fd, int condition,
17+
vu_watch_cb cb, void *data)
18+
{
19+
abort();
20+
}
21+
22+
static void
23+
remove_watch(VuDev *dev, int fd)
24+
{
25+
abort();
26+
}
27+
28+
static const VuDevIface iface = {
29+
0,
30+
};
31+
32+
int
33+
main(int argc, const char *argv[])
34+
{
35+
bool rc;
36+
uint16_t max_queues = 2;
37+
int socket = 0;
38+
VuDev dev = { 0, };
39+
40+
rc = vu_init(&dev, max_queues, socket, panic, NULL, set_watch, remove_watch, &iface);
41+
assert(rc == true);
42+
vu_deinit(&dev);
43+
44+
return 0;
45+
}

subprojects/libvhost-user/meson.build

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ vhost_user = static_library('vhost-user',
1010
include_directories: inc,
1111
c_args: '-D_GNU_SOURCE')
1212

13+
executable('link-test', files('link-test.c'),
14+
link_whole: vhost_user,
15+
include_directories: inc)
16+
1317
vhost_user_glib = static_library('vhost-user-glib',
1418
files('libvhost-user-glib.c'),
1519
include_directories: inc,

0 commit comments

Comments
 (0)