summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-12-10 10:37:47 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-12-10 10:38:08 +0000
commit135a71b643e3935472887c0aece65ff66a2e0627 (patch)
treeca1acb5f26c00be680829bfefbdd9a2fac8baff5
parentAdding patch from upstream to fix udev tests with dummy interfaces, thanks to... (diff)
downloadnvme-stas-135a71b643e3935472887c0aece65ff66a2e0627.tar.xz
nvme-stas-135a71b643e3935472887c0aece65ff66a2e0627.zip
Adding patch from upstream to fix tests with esoteric interface names, thanks to Olivier Gayot <olivier.gayot@canonical.com> (Closes: #1057530).
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--debian/patches/series1
-rw-r--r--debian/patches/upstream/0002-skip-esoteric-interfaces.patch70
2 files changed, 71 insertions, 0 deletions
diff --git a/debian/patches/series b/debian/patches/series
index 8ceb28a..9ebe5cf 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
upstream/0001-test-dummy-interfaces.patch
+upstream/0002-skip-esoteric-interfaces.patch
diff --git a/debian/patches/upstream/0002-skip-esoteric-interfaces.patch b/debian/patches/upstream/0002-skip-esoteric-interfaces.patch
new file mode 100644
index 0000000..4994093
--- /dev/null
+++ b/debian/patches/upstream/0002-skip-esoteric-interfaces.patch
@@ -0,0 +1,70 @@
+Author: Olivier Gayot <olivier.gayot@canonical.com>
+Description: Skip mac2iface test for esoteric interfaces
+ mac2iface takes a MAC address as argument and returns the corresponding
+ interface (if any).
+ The mac2iface tests will however invoke mac2iface with invalid MAC addresses
+ when esoteric network interfaces are present on the system. As an example,
+ armhf autopkgtest runners in Ubuntu have gre interfaces configured so the
+ test-suite fails.
+ .
+ We now ensure that the test-suite calls mac2iface with only valid MAC
+ addresses.
+ .
+ Furthermore, 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.
+ .
+ https://github.com/linux-nvme/nvme-stas/pull/411
+ https://github.com/linux-nvme/nvme-stas/commit/2336eab5b4e4e2f9fd28b7efe425f86e6a23ab91
+
+diff -Naurp nvme-stas.orig/test/test-iputil.py nvme-stas/test/test-iputil.py
+--- nvme-stas.orig/test/test-iputil.py
++++ nvme-stas/test/test-iputil.py
+@@ -43,11 +43,41 @@ class Test(unittest.TestCase):
+ self.assertEqual('', iputil.get_interface(ifaces, ''))
+ self.assertEqual('', iputil.get_interface(ifaces, None))
+
++ @staticmethod
++ def _is_ok_for_mac2iface(iface) -> bool:
++ ''' mac2iface can only work with interfaces that have a proper MAC
++ address. One can use this function to filter out other interfaces
++ configured on the system. '''
++ if iface['link_type'] != 'ether':
++ # Some esoteric interface types (e.g., gre) use the address
++ # field to store something that is not a MAC address. Skip
++ # them.
++ return False
++ if 'address' not in iface:
++ return False
++ if iface['address'] == '00:00:00:00:00:00':
++ # All 0's is an invalid MAC address so do not bother.
++ # In practice, it often appears as the address of the loopback
++ # interface but it can also appear for other things like a gretap
++ # or erspan interface.
++ return False
++ return True
++
+ def test_mac2iface(self):
+- for iface in self.ifaces:
+- address = iface.get('address', None)
+- if address:
+- self.assertEqual(iface['ifname'], iputil.mac2iface(address))
++ # We only test the interfaces that have a MAC address, and a valid one.
++ 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):
+ good_tcp = trid.TID({'transport': 'tcp', 'traddr': '1.1.1.1', 'subsysnqn': '', 'trsvcid': '8009'})