From 75f56fba556b2a69c0e4b483d08b5f530b65ae83 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Mon, 12 Nov 2018 16:43:03 +0100 Subject: [PATCH] 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 --- tests/gpiod-test.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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; } -- 2.30.2