mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
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>
This commit is contained in:
parent
e449232f37
commit
6ddd0636e0
1 changed files with 9 additions and 3 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue