From b548ea76d9af648a1da511b429def54e7e744426 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Thu, 28 Sep 2017 09:56:41 +0200 Subject: [PATCH] tests: new cleanup function Add a new cleanup function which calls gpiod_line_close_chip(). Signed-off-by: Bartosz Golaszewski --- tests/gpiod-test.c | 6 ++++++ tests/gpiod-test.h | 1 + 2 files changed, 7 insertions(+) diff --git a/tests/gpiod-test.c b/tests/gpiod-test.c index 944c3f0..d06276e 100644 --- a/tests/gpiod-test.c +++ b/tests/gpiod-test.c @@ -1019,6 +1019,12 @@ void test_close_chip(struct gpiod_chip **chip) gpiod_chip_close(*chip); } +void test_line_close_chip(struct gpiod_line **line) +{ + if (*line) + gpiod_line_close_chip(*line); +} + void test_free_str(char **str) { if (*str) diff --git a/tests/gpiod-test.h b/tests/gpiod-test.h index 20c8a3d..d588238 100644 --- a/tests/gpiod-test.h +++ b/tests/gpiod-test.h @@ -126,6 +126,7 @@ void test_tool_stdin_write(const char *fmt, ...) TEST_PRINTF(1, 2); * The functions below can be reused by different tests for common use cases. */ void test_close_chip(struct gpiod_chip **chip); +void test_line_close_chip(struct gpiod_line **line); void test_free_str(char **str); void test_free_chip_iter(struct gpiod_chip_iter **iter); void test_free_chip_iter_noclose(struct gpiod_chip_iter **iter); -- 2.30.2