tests: new cleanup function
authorBartosz Golaszewski <bartekgola@gmail.com>
Thu, 28 Sep 2017 07:56:41 +0000 (09:56 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Thu, 28 Sep 2017 07:56:41 +0000 (09:56 +0200)
Add a new cleanup function which calls gpiod_line_close_chip().

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
tests/gpiod-test.c
tests/gpiod-test.h

index 944c3f079f7310917c935831252659a1d4faabec..d06276ea0d3c4a38aad5d5d7ea6f3f0376e62727 100644 (file)
@@ -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)
index 20c8a3d70d2927163300edc52c52653344db039c..d5882384e74fc6b0bc43ab6b1ca3aa3a1bd1e425 100644 (file)
@@ -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);