From 015d73cb54fa7e23aec680febdd9c54e1ca01234 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Thu, 4 Dec 2025 18:20:27 +0200 Subject: [PATCH] tests: bail on dispatch failure Originally the test-asserts were abort()'ing. Then they were changed to record the failure but not abort() anymore. These loops were missed, accidentally turning them into endless loops on Wayland connection failure, e.g. a protocol error. When then loops become endless, they will repeatedly print the assertion failure message. When run as part of the test suite via Meson, Meson will collect all printouts in memory. Therefore the meson process will use memory rapidly without bounds. Break all these loops. Signed-off-by: Pekka Paalanen --- tests/color-management-parametric-test.c | 6 ++++-- tests/color-management-test.c | 3 ++- tests/output-capture-protocol-test.c | 9 ++++++--- tests/presentation-test.c | 3 ++- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/color-management-parametric-test.c b/tests/color-management-parametric-test.c index a3a742a2b..a456e6af2 100644 --- a/tests/color-management-parametric-test.c +++ b/tests/color-management-parametric-test.c @@ -721,7 +721,8 @@ TEST_P(create_parametric_image_description, good_test_cases) image_desc_creator_param = NULL; while (image_desc->status == CM_IMAGE_DESC_NOT_CREATED) - test_assert_int_ge(wl_display_dispatch(client->wl_display), 0); + if (!test_assert_int_ge(wl_display_dispatch(client->wl_display), 0)) + return RESULT_FAIL; test_assert_enum(image_desc->status, CM_IMAGE_DESC_READY); image_description_destroy(image_desc); @@ -837,7 +838,8 @@ TEST_P(fail_to_create_parametric_image_description, bad_test_cases) } while (image_desc->status == CM_IMAGE_DESC_NOT_CREATED) - test_assert_int_ge(wl_display_dispatch(client->wl_display), 0); + if (!test_assert_int_ge(wl_display_dispatch(client->wl_display), 0)) + return RESULT_FAIL; /* This TEST() is for bad params, so we shouldn't be able to * successfully create an image description. */ diff --git a/tests/color-management-test.c b/tests/color-management-test.c index 5cd618dde..9369ec45a 100644 --- a/tests/color-management-test.c +++ b/tests/color-management-test.c @@ -784,7 +784,8 @@ wait_until_image_description_ready(struct client *client, struct image_description *image_descr) { while (image_descr->status == CM_IMAGE_DESC_NOT_CREATED) - test_assert_int_ge(wl_display_dispatch(client->wl_display), 0); + if (!test_assert_int_ge(wl_display_dispatch(client->wl_display), 0)) + break; test_assert_enum(image_descr->status, CM_IMAGE_DESC_READY); } diff --git a/tests/output-capture-protocol-test.c b/tests/output-capture-protocol-test.c index 26470232e..e2e32dd35 100644 --- a/tests/output-capture-protocol-test.c +++ b/tests/output-capture-protocol-test.c @@ -249,7 +249,8 @@ TEST(simple_shot) weston_capture_source_v1_capture(capt->source, buf->proxy); while (!capt->events.reply) - test_assert_int_ge(wl_display_dispatch(client->wl_display), 0); + if (!test_assert_int_ge(wl_display_dispatch(client->wl_display), 0)) + return RESULT_FAIL; test_assert_enum(capt->state, CAPTURE_TASK_COMPLETE); @@ -292,7 +293,8 @@ TEST(retry_on_wrong_format) weston_capture_source_v1_capture(capt->source, buf->proxy); while (!capt->events.reply) - test_assert_int_ge(wl_display_dispatch(client->wl_display), 0); + if (!test_assert_int_ge(wl_display_dispatch(client->wl_display), 0)) + return RESULT_FAIL; test_assert_enum(capt->state, CAPTURE_TASK_RETRY); @@ -331,7 +333,8 @@ TEST(retry_on_wrong_size) weston_capture_source_v1_capture(capt->source, buf->proxy); while (!capt->events.reply) - test_assert_int_ge(wl_display_dispatch(client->wl_display), 0); + if (!test_assert_int_ge(wl_display_dispatch(client->wl_display), 0)) + return RESULT_FAIL; test_assert_enum(capt->state, CAPTURE_TASK_RETRY); diff --git a/tests/presentation-test.c b/tests/presentation-test.c index 96d15c8cf..68e86d678 100644 --- a/tests/presentation-test.c +++ b/tests/presentation-test.c @@ -165,7 +165,8 @@ static void feedback_wait(struct feedback *fb) { while (fb->result == FB_PENDING) { - test_assert_int_ge(wl_display_dispatch(fb->client->wl_display), 0); + if (!test_assert_int_ge(wl_display_dispatch(fb->client->wl_display), 0)) + break; } }