From: Bartosz Golaszewski Date: Mon, 12 Feb 2018 10:55:49 +0000 (+0100) Subject: tests: event: new test case X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=a5a153d691234de1e584a45443c368c9949b9ca8;p=qemu-gpiodev%2Flibgpiod.git tests: event: new test case Verify that the active-low flag is respected when reading line values from lines configured for events. Signed-off-by: Bartosz Golaszewski --- diff --git a/tests/tests-event.c b/tests/tests-event.c index bf800b7..45d5c4e 100644 --- a/tests/tests-event.c +++ b/tests/tests-event.c @@ -171,6 +171,44 @@ TEST_DEFINE(event_get_value, "events - mixing events and gpiod_line_get_value()", 0, { 8 }); +static void event_get_value_active_low(void) +{ + TEST_CLEANUP(test_close_chip) struct gpiod_chip *chip = NULL; + struct timespec ts = { 1, 0 }; + struct gpiod_line_event ev; + struct gpiod_line *line; + int rv; + + chip = gpiod_chip_open(test_chip_path(0)); + TEST_ASSERT_NOT_NULL(chip); + + line = gpiod_chip_get_line(chip, 7); + TEST_ASSERT_NOT_NULL(line); + + rv = gpiod_line_request_falling_edge_events_flags(line, TEST_CONSUMER, + GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW); + TEST_ASSERT_RET_OK(rv); + + rv = gpiod_line_get_value(line); + TEST_ASSERT_EQ(rv, 1); + + test_set_event(0, 7, TEST_EVENT_FALLING, 100); + + rv = gpiod_line_event_wait(line, &ts); + TEST_ASSERT_EQ(rv, 1); + + rv = gpiod_line_event_read(line, &ev); + TEST_ASSERT_RET_OK(rv); + + TEST_ASSERT_EQ(ev.event_type, GPIOD_LINE_EVENT_FALLING_EDGE); + + rv = gpiod_line_get_value(line); + TEST_ASSERT_EQ(rv, 0); +} +TEST_DEFINE(event_get_value_active_low, + "events - mixing events and gpiod_line_get_value() (active-low flag)", + 0, { 8 }); + static void event_wait_multiple(void) { TEST_CLEANUP(test_close_chip) struct gpiod_chip *chip = NULL;