From: Yu Watanabe Date: Thu, 12 Mar 2026 00:19:34 +0000 (+0900) Subject: test: add test cases for device_get_sysattr_int() and friends X-Git-Tag: v261-rc1~125^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbfe8b162b366d48cae5a13dab11e496843d7035;p=thirdparty%2Fsystemd.git test: add test cases for device_get_sysattr_int() and friends --- diff --git a/src/libsystemd/sd-device/test-sd-device.c b/src/libsystemd/sd-device/test-sd-device.c index 9201919898a..13fb9fd25d2 100644 --- a/src/libsystemd/sd-device/test-sd-device.c +++ b/src/libsystemd/sd-device/test-sd-device.c @@ -312,6 +312,24 @@ static void test_sd_device_one(sd_device *d) { ASSERT_OK(device_get_sysattr_safe_string(d, "uevent", &uevent_safe)); ASSERT_STREQ(uevent, uevent_safe); } + + if (sd_device_get_ifindex(d, &ifindex) >= 0) { + int i; + ASSERT_OK_POSITIVE(device_get_sysattr_int(d, "ifindex", &i)); + ASSERT_EQ(i, ifindex); + + unsigned u; + ASSERT_OK_POSITIVE(device_get_sysattr_unsigned(d, "ifindex", &u)); + ASSERT_EQ(u, (unsigned) ifindex); + + uint64_t u64; + ASSERT_OK_POSITIVE(device_get_sysattr_u64(d, "ifindex", &u64)); + ASSERT_EQ(u64, (uint64_t) ifindex); + + uint32_t u32; + ASSERT_OK_POSITIVE(device_get_sysattr_u32(d, "ifindex", &u32)); + ASSERT_EQ(u32, (uint32_t) ifindex); + } } static void exclude_problematic_devices(sd_device_enumerator *e) {