From: Bartosz Golaszewski Date: Wed, 22 Feb 2017 09:55:24 +0000 (+0100) Subject: tests: new cleanup helper X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=b9037255f5663e9ab864fe1a614fb9d0751ae46f;p=qemu-gpiodev%2Flibgpiod.git tests: new cleanup helper Add a new cleanup helper which releases a previously requested GPIO line when a gpiod_line pointer used with GU_CLEANUP() goes out of scope. Signed-off-by: Bartosz Golaszewski --- diff --git a/tests/unit/gpiod-unit.c b/tests/unit/gpiod-unit.c index 04995c1..0e0f55f 100644 --- a/tests/unit/gpiod-unit.c +++ b/tests/unit/gpiod-unit.c @@ -420,3 +420,9 @@ void gu_free_chip_iter(struct gpiod_chip_iter **iter) if (*iter) gpiod_chip_iter_free(*iter); } + +void gu_release_line(struct gpiod_line **line) +{ + if (*line) + gpiod_line_release(*line); +} diff --git a/tests/unit/gpiod-unit.h b/tests/unit/gpiod-unit.h index bda0bd0..824c8c3 100644 --- a/tests/unit/gpiod-unit.h +++ b/tests/unit/gpiod-unit.h @@ -76,6 +76,7 @@ unsigned int gu_chip_num(unsigned int index); void gu_close_chip(struct gpiod_chip **chip); void gu_free_str(char **str); void gu_free_chip_iter(struct gpiod_chip_iter **iter); +void gu_release_line(struct gpiod_line **line); #define GU_ASSERT(statement) \ do { \