From 010207cd0e586ddea4d805deeffb3df4b578eebe Mon Sep 17 00:00:00 2001
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Date: Thu, 13 Apr 2023 16:49:58 +0200
Subject: [PATCH] tests: check the return value of
 gpiod_line_config_add_line_settings()

The call to gpiod_line_config_add_line_settings() can fail in the thread
function used by info-event test cases so check its return value and act
accordingly.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 tests/tests-info-event.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/tests-info-event.c b/tests/tests-info-event.c
index 9f942eb..d069811 100644
--- a/tests/tests-info-event.c
+++ b/tests/tests-info-event.c
@@ -79,8 +79,11 @@ static gpointer request_reconfigure_release_line(gpointer data)
 	gpiod_line_config_reset(ctx->line_cfg);
 	gpiod_line_settings_set_direction(ctx->settings,
 					  GPIOD_LINE_DIRECTION_OUTPUT);
-	gpiod_line_config_add_line_settings(ctx->line_cfg, &ctx->offset, 1,
-					    ctx->settings);
+	ret = gpiod_line_config_add_line_settings(ctx->line_cfg, &ctx->offset,
+						  1, ctx->settings);
+	g_assert_cmpint(ret, ==, 0);
+	if (g_test_failed())
+		return NULL;
 
 	ret = gpiod_line_request_reconfigure_lines(request, ctx->line_cfg);
 	g_assert_cmpint(ret, ==, 0);
-- 
2.30.2