]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-sd-device: skip gpio subsystem 23337/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 11 May 2022 17:00:38 +0000 (02:00 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 12 May 2022 17:51:00 +0000 (02:51 +0900)
There exist /sys/class/gpio and /sys/bus/gpio, and both have gpiochip%N
device. However, these point to different devpaths.

src/libsystemd/sd-device/test-sd-device.c

index 3bd3761f3be6822f9c7107f01852938fbc7c8e93..5e3536be40b24253caf0a6ab2e291706eb116688 100644 (file)
@@ -66,7 +66,11 @@ static void test_sd_device_one(sd_device *d) {
                 assert_se(r == -ENOENT);
 
         r = sd_device_get_subsystem(d, &subsystem);
-        if (r >= 0) {
+        if (r < 0)
+                assert_se(r == -ENOENT);
+        else if (!streq(subsystem, "gpio")) { /* Unfortunately, there exist /sys/class/gpio and /sys/bus/gpio.
+                                               * Hence, sd_device_new_from_subsystem_sysname() and
+                                               * sd_device_new_from_device_id() may not work as expected. */
                 const char *name, *id;
 
                 if (streq(subsystem, "drivers"))
@@ -102,8 +106,7 @@ static void test_sd_device_one(sd_device *d) {
 
                 r = sd_device_get_property_value(d, "ID_NET_DRIVER", &val);
                 assert_se(r >= 0 || r == -ENOENT);
-        } else
-                assert_se(r == -ENOENT);
+        }
 
         is_block = streq_ptr(subsystem, "block");