From 2682dc216483b3da1af89bc80c315344c5e96ea3 Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Mon, 12 Dec 2022 15:04:02 +0900
Subject: [PATCH] test: name_assign_type sysattr never exists for enumerated
 devices

As we filtered out network devices in the test.

(cherry picked from commit 733529d81227ca713de2d6be77939e3bfedb926f)
(cherry picked from commit a8dd94e0cc162d3d020d49af7d1e238b9c7afca3)

Conflict:code context adaptation
Reference:https://github.com/systemd/systemd-stable/commit/2682dc216483b3da1af89bc80c315344c5e96ea3
---
 src/libsystemd/sd-device/test-sd-device.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/libsystemd/sd-device/test-sd-device.c b/src/libsystemd/sd-device/test-sd-device.c
index 01c184a7d0..3e0cfa0ee7 100644
--- a/src/libsystemd/sd-device/test-sd-device.c
+++ b/src/libsystemd/sd-device/test-sd-device.c
@@ -175,15 +175,16 @@ static void test_sd_device_one(sd_device *d) {
                 assert_se((r >= 0 && usec > 0) || r == -ENODATA);
         }
 
-        r = sd_device_get_sysattr_value(d, "name_assign_type", &val);
-        assert_se(r >= 0 || ERRNO_IS_PRIVILEGE(r) || IN_SET(r, -ENOENT, -EINVAL));
-
-        if (r > 0) {
+        r = sd_device_get_sysattr_value(d, "nsid", NULL);
+        if (r >= 0) {
                 unsigned x;
 
-                assert_se(device_get_sysattr_unsigned(d, "name_assign_type", NULL) >= 0);
-                assert_se(device_get_sysattr_unsigned(d, "name_assign_type", &x) >= 0);
-        }
+                assert_se(device_get_sysattr_unsigned(d, "nsid", NULL) >= 0);
+                r = device_get_sysattr_unsigned(d, "nsid", &x);
+                assert_se(r >= 0);
+                assert_se((x > 0) == (r > 0));
+        } else
+                assert_se(ERRNO_IS_PRIVILEGE(r) || IN_SET(r, -ENOENT, -EINVAL));
 
         r = sd_device_get_property_value(d, "ID_NET_DRIVER", &val);
         assert_se(r >= 0 || r == -ENOENT);
-- 
2.33.0

