From: Bartosz Golaszewski Date: Thu, 8 Jun 2017 11:24:36 +0000 (+0200) Subject: tests: allow having zero gpio-mockup chips for tests X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=071baadcea0d9e364dfaa94051c250311eddf0bf;p=qemu-gpiodev%2Flibgpiod.git 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 --- 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)