summaryrefslogtreecommitdiffstats
path: root/test/test-iputil.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-16 11:03:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-16 11:03:18 +0000
commit347467d3fa6fb239f917c05c4cf7f6c3fe7f9b30 (patch)
tree44ae9f59984c8a36b93f29a729f10473653f9f19 /test/test-iputil.py
parentAdding upstream version 2.2.2. (diff)
downloadnvme-stas-347467d3fa6fb239f917c05c4cf7f6c3fe7f9b30.tar.xz
nvme-stas-347467d3fa6fb239f917c05c4cf7f6c3fe7f9b30.zip
Adding upstream version 2.3~rc1.upstream/2.3_rc1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/test-iputil.py')
-rwxr-xr-xtest/test-iputil.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/test/test-iputil.py b/test/test-iputil.py
index 8f364ad..3af734f 100755
--- a/test/test-iputil.py
+++ b/test/test-iputil.py
@@ -1,11 +1,12 @@
#!/usr/bin/python3
import json
import shutil
+import socket
import logging
import unittest
import ipaddress
import subprocess
-from staslib import iputil, log, trid
+from staslib import iputil, log, stas, trid
IP = shutil.which('ip')
@@ -39,6 +40,12 @@ class Test(unittest.TestCase):
self.assertEqual('', iputil.get_interface('255.255.255.255'))
+ def test_mac2iface(self):
+ for iface in self.ifaces:
+ address = iface.get('address', None)
+ if address:
+ self.assertEqual(iface['ifname'], iputil.mac2iface(address))
+
def test_remove_invalid_addresses(self):
good_tcp = trid.TID({'transport': 'tcp', 'traddr': '1.1.1.1', 'subsysnqn': '', 'trsvcid': '8009'})
bad_tcp = trid.TID({'transport': 'tcp', 'traddr': '555.555.555.555', 'subsysnqn': '', 'trsvcid': '8009'})
@@ -51,7 +58,7 @@ class Test(unittest.TestCase):
any_fc,
bad_trtype,
]
- l2 = iputil.remove_invalid_addresses(l1)
+ l2 = stas.remove_invalid_addresses(l1)
self.assertNotEqual(l1, l2)
@@ -61,6 +68,11 @@ class Test(unittest.TestCase):
self.assertNotIn(bad_tcp, l2)
self.assertNotIn(bad_trtype, l2)
+ def test__data_matches_ip(self):
+ self.assertFalse(iputil._data_matches_ip(None, None, None))
+ self.assertFalse(iputil._data_matches_ip(socket.AF_INET, None, None))
+ self.assertFalse(iputil._data_matches_ip(socket.AF_INET6, None, None))
+
if __name__ == "__main__":
unittest.main()