Signed-off-by: Bryce Harrington <br...@osg.samsung.com>
---
 tests/socket-test.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/tests/socket-test.c b/tests/socket-test.c
index bb034f4..1990749 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,30 @@ 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];
+       const char *name = "wayland-test-0";
+       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, name, sock_fd);
+       assert(ret == 0);
+
+       wl_display_destroy(d);
+}
+
 TEST(add_socket_auto)
 {
        /* the number of auto sockets is currently 32,
@@ -173,3 +198,27 @@ TEST(add_socket_auto)
 
        wl_display_destroy(d);
 }
+
+TEST(add_existing_socket_fd_auto)
+{
+       /* Add a new socket using an already existing file descriptor */
+       char path[sizeof example_sockaddr_un.sun_path];
+       const char *name;
+       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);
+
+       name = wl_display_add_socket_fd_auto(d, sock_fd);
+       assert(name != NULL);
+
+       wl_display_destroy(d);
+}
-- 
1.9.1

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to