diff mbox series

[libgpiod,2/5] tests: add a test-case for gpiod_line_request_get_chip_path()

Message ID 20230719192057.172560-3-brgl@bgdev.pl
State Superseded
Headers show
Series core: provide information about the parent chip in line requests | expand

Commit Message

Bartosz Golaszewski July 19, 2023, 7:20 p.m. UTC
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Add a test case for the chip path getter on line-request objects.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 tests/tests-line-request.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
diff mbox series

Patch

diff --git a/tests/tests-line-request.c b/tests/tests-line-request.c
index 0b985e2..2c8c497 100644
--- a/tests/tests-line-request.c
+++ b/tests/tests-line-request.c
@@ -675,3 +675,24 @@  GPIOD_TEST_CASE(get_requested_offsets_less_and_more)
 	g_assert_cmpuint(retrieved[2], ==, 2);
 	g_assert_cmpuint(retrieved[3], ==, 3);
 }
+
+GPIOD_TEST_CASE(get_chip_path)
+{
+	static const guint offset = 4;
+
+	g_autoptr(GPIOSimChip) sim = g_gpiosim_chip_new("num-lines", 8, NULL);
+	g_autoptr(struct_gpiod_chip) chip = NULL;
+	g_autoptr(struct_gpiod_line_config) line_cfg = NULL;
+	g_autoptr(struct_gpiod_line_request) request = NULL;
+
+	chip = gpiod_test_open_chip_or_fail(g_gpiosim_chip_get_dev_path(sim));
+	line_cfg = gpiod_test_create_line_config_or_fail();
+
+	gpiod_test_line_config_add_line_settings_or_fail(line_cfg, &offset, 1,
+							 NULL);
+
+	request = gpiod_test_chip_request_lines_or_fail(chip, NULL, line_cfg);
+
+	g_assert_cmpstr(gpiod_chip_get_path(chip), ==,
+			gpiod_line_request_get_chip_path(request));
+}