Signed-off-by: Bryce Harrington <[email protected]>
---
 tests/socket-test.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/tests/socket-test.c b/tests/socket-test.c
index bb034f4..c58637e 100644
--- a/tests/socket-test.c
+++ b/tests/socket-test.c
@@ -27,6 +27,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <sys/un.h>
+#include <sys/socket.h>
 #include <unistd.h>
 
 #include "wayland-client.h"
@@ -126,6 +127,29 @@ TEST(add_existing_socket)
        wl_display_destroy(d);
 }
 
+TEST(add_existing_socket_fd)
+{
+       /* Add a new socket using an already existing file descriptor */
+       char path[sizeof example_sockaddr_un.sun_path];
+       struct wl_display *d;
+       int ret;
+       int sock_fd;
+
+       /* We have a socket that already exists external from Wayland */
+       sock_fd = socket(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0);
+       assert(sock_fd > 0);
+
+       require_xdg_runtime_dir();
+
+       d = wl_display_create();
+       assert(d != NULL);
+
+       ret = wl_display_add_socket_fd(d, "wayland-test-0", sock_fd);
+       assert(ret == 0);
+
+       wl_display_destroy(d);
+}
+
 TEST(add_socket_auto)
 {
        /* the number of auto sockets is currently 32,
-- 
1.9.1

_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to