From: Yu Watanabe Date: Wed, 23 Mar 2022 05:51:22 +0000 (+0900) Subject: test: add tests for device id X-Git-Tag: v251-rc1~54^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=93e04eb43bed6cd1cea344f8fb1002b62155fae2;p=thirdparty%2Fsystemd.git test: add tests for device id --- diff --git a/src/libsystemd/sd-device/test-sd-device.c b/src/libsystemd/sd-device/test-sd-device.c index 2d2157ba70a..8a534ca8ef2 100644 --- a/src/libsystemd/sd-device/test-sd-device.c +++ b/src/libsystemd/sd-device/test-sd-device.c @@ -12,7 +12,8 @@ #include "time-util.h" static void test_sd_device_one(sd_device *d) { - const char *syspath, *subsystem, *val; + _cleanup_(sd_device_unrefp) sd_device *device_from_id = NULL; + const char *syspath, *subsystem, *id, *val; dev_t devnum; usec_t usec; int i, r; @@ -57,7 +58,17 @@ 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); - log_info("syspath:%s subsystem:%s initialized:%s", syspath, strna(subsystem), yes_no(i)); + r = device_get_device_id(d, &id); + assert_se(r >= 0); + + r = sd_device_new_from_device_id(&device_from_id, id); + assert_se(r >= 0); + + r = sd_device_get_syspath(device_from_id, &val); + assert_se(r >= 0); + assert_se(streq(syspath, val)); + + log_info("syspath:%s subsystem:%s id:%s initialized:%s", syspath, strna(subsystem), id, yes_no(i)); } TEST(sd_device_enumerator_devices) {