From: Bartosz Golaszewski Date: Sun, 7 Oct 2018 08:56:38 +0000 (+0200) Subject: tests: ctxless: add a test case for the event monitor X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=3f667cbdd02f43f15c3e35cb9ca86c37cd5e59b5;p=qemu-gpiodev%2Flibgpiod.git tests: ctxless: add a test case for the event monitor Add a test case verifying that the event callback is not called for events we're not monitoring. Signed-off-by: Bartosz Golaszewski --- diff --git a/tests/tests-ctxless.c b/tests/tests-ctxless.c index 1c47dd3..ea9403d 100644 --- a/tests/tests-ctxless.c +++ b/tests/tests-ctxless.c @@ -165,6 +165,29 @@ TEST_DEFINE(ctxless_event_monitor, "gpiod_ctxless_event_monitor() - single event", 0, { 8 }); +static void ctxless_event_monitor_single_event_type(void) +{ + struct ctxless_event_data evdata = { false, false, 0, 0 }; + struct timespec ts = { 1, 0 }; + int rv; + + test_set_event(0, 3, TEST_EVENT_ALTERNATING, 100); + + rv = gpiod_ctxless_event_monitor(test_chip_name(0), + GPIOD_CTXLESS_EVENT_FALLING_EDGE, + 3, false, TEST_CONSUMER, &ts, + NULL, ctxless_event_cb, &evdata); + + TEST_ASSERT_RET_OK(rv); + TEST_ASSERT(evdata.got_falling_edge); + TEST_ASSERT_FALSE(evdata.got_rising_edge); + TEST_ASSERT_EQ(evdata.count, 2); + TEST_ASSERT_EQ(evdata.offset, 3); +} +TEST_DEFINE(ctxless_event_monitor_single_event_type, + "gpiod_ctxless_event_monitor() - specify event type", + 0, { 8 }); + static void ctxless_event_monitor_multiple(void) { struct ctxless_event_data evdata = { false, false, 0, 0 };