aboutsummaryrefslogtreecommitdiffstats
path: root/tests/display-test.c
diff options
context:
space:
mode:
authorManuel Stoeckl <code@mstoeckl.com>2020-01-11 12:38:46 -0500
committerPekka Paalanen <pq@iki.fi>2020-01-15 13:18:56 +0000
commit6ddd0636e0d4124c64993329b11a6c656a1841df (patch)
tree0e2d71f59a135bd25169f9bfb5e5f0635571ad64 /tests/display-test.c
parenttests: Fix race condition in send overflow test (diff)
downloadwayland-6ddd0636e0d4124c64993329b11a6c656a1841df.tar
wayland-6ddd0636e0d4124c64993329b11a6c656a1841df.tar.gz
wayland-6ddd0636e0d4124c64993329b11a6c656a1841df.tar.bz2
wayland-6ddd0636e0d4124c64993329b11a6c656a1841df.tar.lz
wayland-6ddd0636e0d4124c64993329b11a6c656a1841df.tar.xz
wayland-6ddd0636e0d4124c64993329b11a6c656a1841df.tar.zst
wayland-6ddd0636e0d4124c64993329b11a6c656a1841df.zip
tests: Ensure that overflow test always overflows
While the default Unix socket buffer size on Linux is relatively small, on some computers the default size may be configured to be huge, making the overflow test never actually overflow the Wayland display socket. The changed code now explicitly sets the display socket send buffer size to be small enough to guarantee an overflow. Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
Diffstat (limited to 'tests/display-test.c')
-rw-r--r--tests/display-test.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/display-test.c b/tests/display-test.c
index f155d08..3db7c95 100644
--- a/tests/display-test.c
+++ b/tests/display-test.c
@@ -1430,13 +1430,19 @@ send_overflow_client(void *data)
int i, err = 0;
int *pipes = data;
char tmp = '\0';
+ int sock, optval = 16384;
+
+ /* Limit the send buffer size for the display socket to guarantee
+ * that the test will cause an overflow. */
+ sock = wl_display_get_fd(c->wl_display);
+ assert(setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &optval, sizeof(optval)) == 0);
/* Request to break out of 'display_run' in the main process */
assert(stop_display(c, 1) >= 0);
- /* On Linux, the Unix socket default buffer size is <=256KB, and
- * each noop request requires 8 bytes; the buffer should thus
- * overflow within about 32K /unhandled/ iterations */
+ /* On Linux, the actual socket data + metadata space is twice `optval`;
+ * since each noop request requires 8 bytes, the buffer should overflow
+ * within <=4096 iterations. */
for (i = 0; i < 1000000; i++) {
noop_request(c);
err = wl_display_get_error(c->wl_display);