From b7c5026e51e43a62c34a9606e08e8a6f80f83ba2 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Thu, 2 Mar 2017 11:08:58 +0100 Subject: [PATCH] tests: add a test case for a bad line request Implement a test case in which we try to request lines from different GPIO chips in a single bulk object. Signed-off-by: Bartosz Golaszewski --- tests/unit/tests-line.c | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/unit/tests-line.c b/tests/unit/tests-line.c index 91a81de..fc7274c 100644 --- a/tests/unit/tests-line.c +++ b/tests/unit/tests-line.c @@ -131,6 +131,51 @@ GU_DEFINE_TEST(line_request_bulk_output, "gpiod_line_request_bulk_output()", GU_LINES_UNNAMED, { 8, 8 }); +static void line_request_bulk_different_chips(void) +{ + GU_CLEANUP(gu_close_chip) struct gpiod_chip *chipA = NULL; + GU_CLEANUP(gu_close_chip) struct gpiod_chip *chipB = NULL; + struct gpiod_line_request_config req; + struct gpiod_line *lineA0 = NULL; + struct gpiod_line *lineA1 = NULL; + struct gpiod_line *lineB0 = NULL; + struct gpiod_line *lineB1 = NULL; + struct gpiod_line_bulk bulk; + int status; + + chipA = gpiod_chip_open(gu_chip_path(0)); + chipB = gpiod_chip_open(gu_chip_path(1)); + GU_ASSERT_NOT_NULL(chipA); + GU_ASSERT_NOT_NULL(chipB); + + lineA0 = gpiod_chip_get_line(chipA, 0); + lineA1 = gpiod_chip_get_line(chipA, 1); + lineB0 = gpiod_chip_get_line(chipB, 0); + lineB1 = gpiod_chip_get_line(chipB, 1); + + GU_ASSERT_NOT_NULL(lineA0); + GU_ASSERT_NOT_NULL(lineA1); + GU_ASSERT_NOT_NULL(lineB0); + GU_ASSERT_NOT_NULL(lineB1); + + gpiod_line_bulk_init(&bulk); + gpiod_line_bulk_add(&bulk, lineA0); + gpiod_line_bulk_add(&bulk, lineA1); + gpiod_line_bulk_add(&bulk, lineB0); + gpiod_line_bulk_add(&bulk, lineB1); + + req.consumer = "gpiod-unit"; + req.direction = GPIOD_DIRECTION_INPUT; + req.active_state = GPIOD_ACTIVE_STATE_HIGH; + + status = gpiod_line_request_bulk(&bulk, &req, NULL); + GU_ASSERT_NOTEQ(status, 0); + GU_ASSERT_EQ(gpiod_errno(), GPIOD_EBULKINCOH); +} +GU_DEFINE_TEST(line_request_bulk_different_chips, + "gpiod_line_request_bulk() different chips", + GU_LINES_UNNAMED, { 8, 8 }); + static void line_set_value(void) { GU_CLEANUP(gu_close_chip) struct gpiod_chip *chip = NULL; -- 2.30.2