From: Bartosz Golaszewski Date: Mon, 12 Nov 2018 15:43:03 +0000 (+0100) Subject: tests: ignore 'remove' events from udev X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=75f56fba556b2a69c0e4b483d08b5f530b65ae83;p=qemu-gpiodev%2Flibgpiod.git tests: ignore 'remove' events from udev So far the tests have been executed on a Debian 9 machine with libudev provided by systemd 232 - everything always worked fine. However running them on a system with systemd 237 uncovered a bug in the testing framework. It turned out that on newer versions the ignored 'remove' events linger somewhere in the pipeline and get read by subsequent test cases causing erroneous chip naming and breaking tests. Check the action string for udev device objects and only care about those being added. Signed-off-by: Bartosz Golaszewski --- diff --git a/tests/gpiod-test.c b/tests/gpiod-test.c index 92d6b78..0177301 100644 --- a/tests/gpiod-test.c +++ b/tests/gpiod-test.c @@ -810,7 +810,7 @@ static bool devpath_is_mockup(const char *devpath) static void prepare_test(struct _test_chip_descr *descr) { - const char *devpath, *devnode, *sysname; + const char *devpath, *devnode, *sysname, *action; struct udev_monitor *monitor; unsigned int detected = 0; struct test_context *ctx; @@ -868,9 +868,11 @@ static void prepare_test(struct _test_chip_descr *descr) devpath = udev_device_get_devpath(dev); devnode = udev_device_get_devnode(dev); sysname = udev_device_get_sysname(dev); + action = udev_device_get_action(dev); if (!devpath || !devnode || !sysname || - !devpath_is_mockup(devpath)) { + !devpath_is_mockup(devpath) || + strcmp(action, "add") != 0) { udev_device_unref(dev); continue; }