[PATCH wayland v3 7/7] socket-test: Add cases for sockets using existing fd's

Bryce Harrington bryce at osg.samsung.com
Mon Dec 7 22:49:19 PST 2015


Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>
---
 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



More information about the wayland-devel mailing list