From: Bartosz Golaszewski <bartekgola@gmail.com>
Date: Thu, 28 Sep 2017 07:56:41 +0000 (+0200)
Subject: tests: new cleanup function
X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=b548ea76d9af648a1da511b429def54e7e744426;p=qemu-gpiodev%2Flibgpiod.git

tests: new cleanup function

Add a new cleanup function which calls gpiod_line_close_chip().

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
---

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);