summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-03-23 06:51:22 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-03-23 13:57:39 +0100
commit93e04eb43bed6cd1cea344f8fb1002b62155fae2 (patch)
tree4f79d64fd1606be4c46c65eae9e0a7200e921f23
parentsd-device: use path_find_last_component() to set driver subsystem (diff)
downloadsystemd-93e04eb43bed6cd1cea344f8fb1002b62155fae2.tar.xz
systemd-93e04eb43bed6cd1cea344f8fb1002b62155fae2.zip
test: add tests for device id
Diffstat (limited to '')
-rw-r--r--src/libsystemd/sd-device/test-sd-device.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/libsystemd/sd-device/test-sd-device.c b/src/libsystemd/sd-device/test-sd-device.c
index 2d2157ba70..8a534ca8ef 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) {