]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
test: add test for the new portdescription-source option 763/head
authortcollet <tcollet@iliad-free.fr>
Wed, 18 Feb 2026 15:55:18 +0000 (16:55 +0100)
committertcollet <tcollet@iliad-free.fr>
Thu, 19 Feb 2026 11:27:07 +0000 (12:27 +0100)
test result:
- 148 passed
- 7 skipped
- 0 failed

tests/integration/test_basic.py
tests/integration/test_lldpcli.py

index 642f44f608107db3ee3a2fc4b9a59b6ecfb86a1f..0b4a2070bf210bf55966c6be6355cfec9058e802 100644 (file)
@@ -375,6 +375,47 @@ def test_portid_subtype_local_with_alias(lldpd1, lldpd, lldpcli, namespaces):
         assert out["lldp.eth0.port.descr"] == "alias of eth1"
 
 
+@pytest.mark.parametrize(
+    "portid, portdescr_src, expected_descr",
+    [
+        # auto: alias used when portid is not macaddress
+        ("ifname", "auto", "alias of eth1"),
+        # ifname: always use ifname
+        ("ifname", "ifname", "eth1"),
+        # alias: alias used regardless of portid
+        ("ifname", "alias", "alias of eth1"),
+        # auto: alias NOT used when portid is macaddress
+        ("macaddress", "auto", "eth1"),
+        # ifname: always use ifname
+        ("macaddress", "ifname", "eth1"),
+        # alias: alias used even with macaddress portid
+        ("macaddress", "alias", "alias of eth1"),
+    ],
+    ids=[
+        "ifname-auto",
+        "ifname-ifname",
+        "ifname-alias",
+        "macaddress-auto",
+        "macaddress-ifname",
+        "macaddress-alias",
+    ],
+)
+def test_portdescr_source(
+    lldpd1, lldpd, lldpcli, namespaces, portid, portdescr_src, expected_descr
+):
+    with namespaces(2):
+        with pyroute2.IPRoute() as ipr:
+            idx = ipr.link_lookup(ifname="eth1")[0]
+            ipr.link("set", index=idx, ifalias="alias of eth1")
+        lldpd()
+        lldpcli("configure", "lldp", "portidsubtype", portid)
+        lldpcli("configure", "lldp", "portdescription-source", portdescr_src)
+        time.sleep(3)
+    with namespaces(1):
+        out = lldpcli("-f", "keyvalue", "show", "neighbors")
+        assert out["lldp.eth0.port.descr"] == expected_descr
+
+
 def test_port_status_txonly(lldpd, lldpcli, namespaces, links):
     links(namespaces(1), namespaces(2))
     with namespaces(1):
index 4e9262d7629059f5d1699699f6f21846b4a37b90..d4c11ceb05838aa5f540430ae4fa4f56b43b6a13 100644 (file)
@@ -738,6 +738,16 @@ def test_return_code(lldpd1, lldpcli, namespaces):
             "lldp-agent-type",
             "nearest customer bridge",
         ),
+        (
+            "configure lldp portdescription-source ifname",
+            "lldp-portdescr-type",
+            "ifname",
+        ),
+        (
+            "configure lldp portdescription-source alias",
+            "lldp-portdescr-type",
+            "alias",
+        ),
     ],
 )
 def test_config_change(lldpd1, lldpcli, namespaces, command, name, expected):