mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-04-03 07:15:42 -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 i, err = 0;
|
||||||
int *pipes = data;
|
int *pipes = data;
|
||||||
char tmp = '\0';
|
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 */
|
/* Request to break out of 'display_run' in the main process */
|
||||||
assert(stop_display(c, 1) >= 0);
|
assert(stop_display(c, 1) >= 0);
|
||||||
|
|
||||||
/* On Linux, the Unix socket default buffer size is <=256KB, and
|
/* On Linux, the actual socket data + metadata space is twice `optval`;
|
||||||
* each noop request requires 8 bytes; the buffer should thus
|
* since each noop request requires 8 bytes, the buffer should overflow
|
||||||
* overflow within about 32K /unhandled/ iterations */
|
* within <=4096 iterations. */
|
||||||
for (i = 0; i < 1000000; i++) {
|
for (i = 0; i < 1000000; i++) {
|
||||||
noop_request(c);
|
noop_request(c);
|
||||||
err = wl_display_get_error(c->wl_display);
|
err = wl_display_get_error(c->wl_display);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue