From 148e0816bbf4e458d45b44c044f5d69081fd6731 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Tue, 5 Dec 2023 21:33:56 +0100 Subject: [PATCH] Skip mac2iface test when multiple interfaces have the same MAC Sometimes, the same MAC address is assigned to more than one interface on the system (this is true for VLAN interfaces for instance). This confuses mac2iface, which returns only the first match. This scenario is possibly more of a nvme-stas bug than a test-suite bug, but for now we will just skip the interfaces that have a duplicate MAC address. $ ip link add link eth0 name eth0.222 type vlan id 222 $ ip -j addr show dev eth0 | jq '.[]["address"]' "00:16:3e:36:b5:0e" $ ip -j addr show dev eth0.222 | jq '.[]["address"]' "00:16:3e:36:b5:0e" Signed-off-by: Olivier Gayot --- test/test-iputil.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/test-iputil.py b/test/test-iputil.py index aee7e16..3a45605 100755 --- a/test/test-iputil.py +++ b/test/test-iputil.py @@ -68,6 +68,15 @@ def test_mac2iface(self): candidate_ifaces = [iface for iface in self.ifaces if self._is_ok_for_mac2iface(iface)] for iface in candidate_ifaces: + if len([x for x in candidate_ifaces if x['address'] == iface['address']]) >= 2: + # We need to be careful, sometimes we can have the same MAC address + # on multiple interfaces. This happens with VLAN interfaces for + # instance. mac2iface will obviously be confused when dealing with + # those so let's skip the interfaces that have duplicate MAC. + logging.warning('[%s] is not the only interface with address [%s]', + iface['ifname'], iface['address']) + continue + self.assertEqual(iface['ifname'], iputil.mac2iface(iface['address'])) def test_remove_invalid_addresses(self):