[PATCH 5/5] socket-test: Add cases for sockets using existing fd's
Bryce Harrington
bryce at osg.samsung.com
Thu Nov 19 01:36:25 PST 2015
From: Bryce Harrington <bryce at bryceharrington.org>
Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>
---
tests/socket-test.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/tests/socket-test.c b/tests/socket-test.c
index ad07f7a..f70c69b 100644
--- a/tests/socket-test.c
+++ b/tests/socket-test.c
@@ -127,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];
+ const char *name = "wayland-test-0";
+ 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,
@@ -174,3 +197,26 @@ 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;
+ 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
More information about the wayland-devel
mailing list