tests: add a test case for gpiod_line_active_state()
authorBartosz Golaszewski <bartekgola@gmail.com>
Fri, 5 May 2017 17:07:35 +0000 (19:07 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Fri, 5 May 2017 17:07:35 +0000 (19:07 +0200)
Verify that the active state is changed correctly depending on the
parameters of the request.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
tests/unit/tests-line.c

index 0678939021c34a15963315c8e9d763d2010da099..8a389d6cdc2d01bc7e74903d4a5ae84869dc1c3d 100644 (file)
@@ -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 });