From 114e0dc0d3ff11d83a2ab2778896de6568dbdb35 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Fri, 5 May 2017 19:07:35 +0200 Subject: [PATCH] tests: add a test case for gpiod_line_active_state() Verify that the active state is changed correctly depending on the parameters of the request. Signed-off-by: Bartosz Golaszewski --- tests/unit/tests-line.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/unit/tests-line.c b/tests/unit/tests-line.c index 0678939..8a389d6 100644 --- a/tests/unit/tests-line.c +++ b/tests/unit/tests-line.c @@ -292,3 +292,31 @@ static void line_direction(void) GU_DEFINE_TEST(line_direction, "gpiod_line_direction() - set & get", GU_LINES_UNNAMED, { 8 }); + +static void line_active_state(void) +{ + GU_CLEANUP(gu_close_chip) struct gpiod_chip *chip = NULL; + struct gpiod_line *line; + int status; + + chip = gpiod_chip_open(gu_chip_path(0)); + GU_ASSERT_NOT_NULL(chip); + + line = gpiod_chip_get_line(chip, 5); + GU_ASSERT_NOT_NULL(line); + + status = gpiod_line_request_input(line, "gpiod-unit", false); + GU_ASSERT_RET_OK(status); + + GU_ASSERT_EQ(gpiod_line_active_state(line), GPIOD_ACTIVE_STATE_HIGH); + + gpiod_line_release(line); + + status = gpiod_line_request_input(line, "gpiod-unit", true); + GU_ASSERT_RET_OK(status); + + GU_ASSERT_EQ(gpiod_line_direction(line), GPIOD_ACTIVE_STATE_LOW); +} +GU_DEFINE_TEST(line_active_state, + "gpiod_line_active_state() - set & get", + GU_LINES_UNNAMED, { 8 }); -- 2.30.2