From: Bartosz Golaszewski Date: Thu, 2 Mar 2017 16:03:56 +0000 (+0100) Subject: tests: add a test case for busy lines X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=192807fcda05939f8bf314c2a08c814b7ad3f35c;p=qemu-gpiodev%2Flibgpiod.git tests: add a test case for busy lines Run a scenario in which we try to request a line twice and verify that the second attempt fails. Signed-off-by: Bartosz Golaszewski --- diff --git a/tests/unit/tests-line.c b/tests/unit/tests-line.c index 8ab4c1b..a6b0026 100644 --- a/tests/unit/tests-line.c +++ b/tests/unit/tests-line.c @@ -40,6 +40,29 @@ GU_DEFINE_TEST(line_request_output, "gpiod_line_request_output() - good", GU_LINES_UNNAMED, { 8 }); +static void line_request_already_requested(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, 0); + GU_ASSERT_NOT_NULL(line); + + status = gpiod_line_request_input(line, "gpiod-unit", false); + GU_ASSERT_RET_OK(status); + + status = gpiod_line_request_input(line, "gpiod-unit", false); + GU_ASSERT_NOTEQ(status, 0); + GU_ASSERT_EQ(gpiod_errno(), GPIOD_ELINEBUSY); +} +GU_DEFINE_TEST(line_request_already_requested, + "gpiod_line_request() - already requested", + GU_LINES_UNNAMED, { 8 }); + static void line_request_bulk_output(void) { GU_CLEANUP(gu_close_chip) struct gpiod_chip *chipA = NULL;