aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartosz Golaszewski <bartekgola@gmail.com>2018-10-02 17:23:30 +0200
committerBartosz Golaszewski <bartekgola@gmail.com>2018-10-07 10:39:13 +0200
commitcd6f1a4b8397b21aa1df36e68c230b31bd97777b (patch)
tree5ec96b07ab56b250f1d29360eac91400d4a2b47c
parent093b90b2368b1024b92af4433ed3c6b452e5c0d9 (diff)
downloadlibgpiod-cd6f1a4b8397b21aa1df36e68c230b31bd97777b.tar.gz
tests: ctxless: switch to using the event monitor routines
Use gpiod_ctxless_event_monitor() and gpiod_ctxless_event_monitor_multiple() instead of gpiod_ctxless_event_loop() and gpiod_ctxless_event_loop_multiple() respectively. Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
-rw-r--r--tests/tests-ctxless.c54
1 files changed, 29 insertions, 25 deletions
diff --git a/tests/tests-ctxless.c b/tests/tests-ctxless.c
index db8585df..1c47dd31 100644
--- a/tests/tests-ctxless.c
+++ b/tests/tests-ctxless.c
@@ -142,7 +142,7 @@ static int ctxless_event_cb(int evtype, unsigned int offset,
: GPIOD_CTXLESS_EVENT_CB_RET_OK;
}
-static void ctxless_event_loop(void)
+static void ctxless_event_monitor(void)
{
struct ctxless_event_data evdata = { false, false, 0, 0 };
struct timespec ts = { 1, 0 };
@@ -150,9 +150,10 @@ static void ctxless_event_loop(void)
test_set_event(0, 3, TEST_EVENT_ALTERNATING, 100);
- status = gpiod_ctxless_event_loop(test_chip_name(0), 3, false,
- TEST_CONSUMER, &ts, NULL,
- ctxless_event_cb, &evdata);
+ status = gpiod_ctxless_event_monitor(test_chip_name(0),
+ GPIOD_CTXLESS_EVENT_BOTH_EDGES,
+ 3, false, TEST_CONSUMER, &ts,
+ NULL, ctxless_event_cb, &evdata);
TEST_ASSERT_RET_OK(status);
TEST_ASSERT(evdata.got_rising_edge);
@@ -160,11 +161,11 @@ static void ctxless_event_loop(void)
TEST_ASSERT_EQ(evdata.count, 2);
TEST_ASSERT_EQ(evdata.offset, 3);
}
-TEST_DEFINE(ctxless_event_loop,
- "gpiod_ctxless_event_loop() - single event",
+TEST_DEFINE(ctxless_event_monitor,
+ "gpiod_ctxless_event_monitor() - single event",
0, { 8 });
-static void ctxless_event_loop_multiple(void)
+static void ctxless_event_monitor_multiple(void)
{
struct ctxless_event_data evdata = { false, false, 0, 0 };
struct timespec ts = { 1, 0 };
@@ -178,10 +179,11 @@ static void ctxless_event_loop_multiple(void)
test_set_event(0, 3, TEST_EVENT_ALTERNATING, 100);
- status = gpiod_ctxless_event_loop_multiple(test_chip_name(0), offsets,
- 4, false, TEST_CONSUMER,
- &ts, NULL, ctxless_event_cb,
- &evdata);
+ status = gpiod_ctxless_event_monitor_multiple(
+ test_chip_name(0),
+ GPIOD_CTXLESS_EVENT_BOTH_EDGES,
+ offsets, 4, false, TEST_CONSUMER,
+ &ts, NULL, ctxless_event_cb, &evdata);
TEST_ASSERT_RET_OK(status);
TEST_ASSERT(evdata.got_rising_edge);
@@ -189,8 +191,8 @@ static void ctxless_event_loop_multiple(void)
TEST_ASSERT_EQ(evdata.count, 2);
TEST_ASSERT_EQ(evdata.offset, 3);
}
-TEST_DEFINE(ctxless_event_loop_multiple,
- "gpiod_ctxless_event_loop_multiple() - single event",
+TEST_DEFINE(ctxless_event_monitor_multiple,
+ "gpiod_ctxless_event_monitor_multiple() - single event",
0, { 8 });
static int error_event_cb(int evtype TEST_UNUSED,
@@ -203,38 +205,40 @@ static int error_event_cb(int evtype TEST_UNUSED,
return GPIOD_CTXLESS_EVENT_CB_RET_ERR;
}
-static void ctxless_event_loop_indicate_error(void)
+static void ctxless_event_monitor_indicate_error(void)
{
struct timespec ts = { 1, 0 };
int rv;
test_set_event(0, 3, TEST_EVENT_ALTERNATING, 100);
- rv = gpiod_ctxless_event_loop(test_chip_name(0), 3, false,
- TEST_CONSUMER, &ts, NULL,
- error_event_cb, NULL);
+ rv = gpiod_ctxless_event_monitor(test_chip_name(0),
+ GPIOD_CTXLESS_EVENT_BOTH_EDGES,
+ 3, false, TEST_CONSUMER, &ts,
+ NULL, error_event_cb, NULL);
TEST_ASSERT_EQ(rv, -1);
TEST_ASSERT_ERRNO_IS(ENOTBLK);
}
-TEST_DEFINE(ctxless_event_loop_indicate_error,
- "gpiod_ctxless_event_loop() - error in callback",
+TEST_DEFINE(ctxless_event_monitor_indicate_error,
+ "gpiod_ctxless_event_monitor() - error in callback",
0, { 8 });
-static void ctxless_event_loop_indicate_error_timeout(void)
+static void ctxless_event_monitor_indicate_error_timeout(void)
{
struct timespec ts = { 0, 100000 };
int rv;
- rv = gpiod_ctxless_event_loop(test_chip_name(0), 3, false,
- TEST_CONSUMER, &ts, NULL,
- error_event_cb, NULL);
+ rv = gpiod_ctxless_event_monitor(test_chip_name(0),
+ GPIOD_CTXLESS_EVENT_BOTH_EDGES,
+ 3, false, TEST_CONSUMER, &ts,
+ NULL, error_event_cb, NULL);
TEST_ASSERT_EQ(rv, -1);
TEST_ASSERT_ERRNO_IS(ENOTBLK);
}
-TEST_DEFINE(ctxless_event_loop_indicate_error_timeout,
- "gpiod_ctxless_event_loop() - error in callback after timeout",
+TEST_DEFINE(ctxless_event_monitor_indicate_error_timeout,
+ "gpiod_ctxless_event_monitor() - error in callback after timeout",
0, { 8 });
static void ctxless_find_line_good(void)