From 071baadcea0d9e364dfaa94051c250311eddf0bf Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Thu, 8 Jun 2017 13:24:36 +0200 Subject: [PATCH] tests: allow having zero gpio-mockup chips for tests We may have tests which don't require any gpio-mockup chips to be present. When an empty array is given as the list of chip line counts, the gpio-mockup module will not be loaded. Signed-off-by: Bartosz Golaszewski --- tests/gpiod-test.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/gpiod-test.c b/tests/gpiod-test.c index e0dd923..ae76dfb 100644 --- a/tests/gpiod-test.c +++ b/tests/gpiod-test.c @@ -644,6 +644,9 @@ static void load_module(struct _test_chip_descr *descr) char *modarg; int status; + if (descr->num_chips == 0) + return; + modarg = xappend(NULL, "gpio_mockup_ranges="); for (i = 0; i < descr->num_chips; i++) modarg = xappend(modarg, "-1,%u,", descr->num_lines[i]); @@ -836,9 +839,11 @@ static void teardown_test(void) free(globals.test_ctx.chips); - status = kmod_module_remove_module(globals.module, 0); - if (status) - die_perr("unable to remove gpio-mockup"); + if (mockup_loaded()) { + status = kmod_module_remove_module(globals.module, 0); + if (status) + die_perr("unable to remove gpio-mockup"); + } } int main(int argc TEST_UNUSED, char **argv) -- 2.30.2