tests: fix a potential assert() abort()
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Sun, 19 Feb 2023 20:39:03 +0000 (21:39 +0100)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Sun, 19 Feb 2023 20:39:03 +0000 (21:39 +0100)
If info is NULL in one of the line-info test cases, we'll still try to
read its property leading to an abort() triggered from assert(info). Just
bail out of the test function if gpiod_chip_get_line_info() fails.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
tests/tests-line-info.c

index 137084ec7ad9b74701accdf099af8e92aeb27b08..75b38f033c68ce3cf2946281d29ee32a3e472478 100644 (file)
@@ -19,8 +19,7 @@ GPIOD_TEST_CASE(get_line_info_good)
 
        chip = gpiod_test_open_chip_or_fail(g_gpiosim_chip_get_dev_path(sim));
 
-       info = gpiod_chip_get_line_info(chip, 3);
-       g_assert_nonnull(info);
+       info = gpiod_test_get_line_info_or_fail(chip, 3);
        g_assert_cmpuint(gpiod_line_info_get_offset(info), ==, 3);
 }