summaryrefslogtreecommitdiffstats
path: root/test/test-udev.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test-udev.py')
-rwxr-xr-xtest/test-udev.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/test-udev.py b/test/test-udev.py
index 71e5f8a..9508de4 100755
--- a/test/test-udev.py
+++ b/test/test-udev.py
@@ -33,6 +33,7 @@ def get_tids_to_test(family, src_ip, ifname):
'subsysnqn': 'hello',
'host-traddr': src_ip,
'host-iface': ifname,
+ 'host-nqn': '',
}
),
True,
@@ -47,6 +48,7 @@ def get_tids_to_test(family, src_ip, ifname):
'subsysnqn': 'hello',
'host-traddr': src_ip,
'host-iface': ifname,
+ 'host-nqn': '',
}
),
False,
@@ -61,6 +63,7 @@ def get_tids_to_test(family, src_ip, ifname):
'subsysnqn': 'hello',
'host-traddr': src_ip,
'host-iface': ifname,
+ 'host-nqn': '',
}
),
False,
@@ -75,6 +78,7 @@ def get_tids_to_test(family, src_ip, ifname):
'subsysnqn': 'hello',
'host-traddr': src_ip,
'host-iface': ifname,
+ 'host-nqn': '',
}
),
False,
@@ -89,6 +93,7 @@ def get_tids_to_test(family, src_ip, ifname):
'subsysnqn': 'hello',
'host-traddr': '255.255.255.255',
'host-iface': ifname,
+ 'host-nqn': '',
}
),
False,
@@ -103,6 +108,7 @@ def get_tids_to_test(family, src_ip, ifname):
'subsysnqn': 'hello',
'host-traddr': src_ip,
'host-iface': 'blah',
+ 'host-nqn': '',
}
),
False,
@@ -117,6 +123,7 @@ def get_tids_to_test(family, src_ip, ifname):
'subsysnqn': 'bob',
'host-traddr': src_ip,
'host-iface': ifname,
+ 'host-nqn': '',
}
),
False,
@@ -130,6 +137,7 @@ def get_tids_to_test(family, src_ip, ifname):
'trsvcid': '8009',
'subsysnqn': 'hello',
'host-iface': ifname,
+ 'host-nqn': '',
}
),
True,
@@ -143,6 +151,7 @@ def get_tids_to_test(family, src_ip, ifname):
'trsvcid': '8009',
'subsysnqn': 'hello',
'host-traddr': src_ip,
+ 'host-nqn': '',
}
),
True,
@@ -155,6 +164,7 @@ def get_tids_to_test(family, src_ip, ifname):
'traddr': traddr(family),
'trsvcid': '8009',
'subsysnqn': 'hello',
+ 'host-nqn': '',
}
),
True,
@@ -169,6 +179,7 @@ def get_tids_to_test(family, src_ip, ifname):
'subsysnqn': 'hello',
'host-traddr': src_ip,
'host-iface': ifname,
+ 'host-nqn': '',
}
),
True,
@@ -182,6 +193,7 @@ def get_tids_to_test(family, src_ip, ifname):
'trsvcid': '8009',
'subsysnqn': 'hello',
'host-iface': ifname,
+ 'host-nqn': '',
}
),
True,
@@ -296,6 +308,7 @@ class Test(unittest.TestCase):
'host-traddr': src_ipv4,
'host-iface': ifname,
'src-addr': src_ipv4,
+ 'host-nqn': '',
}
cid_legacy = {
'transport': 'tcp',
@@ -305,6 +318,7 @@ class Test(unittest.TestCase):
'host-traddr': src_ipv4,
'host-iface': ifname,
'src-addr': '', # Legacy
+ 'host-nqn': '',
}
for case_id, tid, match in get_tids_to_test(4, src_ipv4, ifname):
self.assertEqual(match, udev.UDEV._cid_matches_tid(tid, cid), msg=f'Test Case {case_id} failed')
@@ -321,6 +335,7 @@ class Test(unittest.TestCase):
'host-traddr': '',
'host-iface': '',
'src-addr': '', # Legacy
+ 'host-nqn': '',
}
tid = trid.TID(
{
@@ -329,6 +344,7 @@ class Test(unittest.TestCase):
'trsvcid': '8009',
'subsysnqn': 'hello',
'host-traddr': '1.1.1.1',
+ 'host-nqn': '',
}
)
self.assertEqual(True, udev.UDEV._cid_matches_tid(tid, cid_legacy), msg=f'Legacy Test Case A4.1 failed')
@@ -341,6 +357,7 @@ class Test(unittest.TestCase):
'host-traddr': '',
'host-iface': ifname,
'src-addr': '', # Legacy
+ 'host-nqn': '',
}
tid = trid.TID(
{
@@ -348,6 +365,7 @@ class Test(unittest.TestCase):
'traddr': traddr(4),
'trsvcid': '8009',
'subsysnqn': 'hello',
+ 'host-nqn': '',
}
)
self.assertEqual(True, udev.UDEV._cid_matches_tid(tid, cid_legacy), msg=f'Legacy Test Case A4.2 failed')
@@ -363,6 +381,7 @@ class Test(unittest.TestCase):
'host-traddr': src_ipv4,
'host-iface': '',
'src-addr': '', # Legacy
+ 'host-nqn': '',
}
tid = trid.TID(
{
@@ -371,6 +390,7 @@ class Test(unittest.TestCase):
'trsvcid': '8009',
'subsysnqn': 'hello',
'host-traddr': '1.1.1.1',
+ 'host-nqn': '',
}
)
self.assertEqual(False, udev.UDEV._cid_matches_tid(tid, cid_legacy), msg=f'Legacy Test Case B4 failed')
@@ -382,6 +402,7 @@ class Test(unittest.TestCase):
'trsvcid': '8009',
'subsysnqn': 'hello',
'host-iface': 'blah',
+ 'host-nqn': '',
}
)
self.assertEqual(False, udev.UDEV._cid_matches_tid(tid, cid_legacy), msg=f'Legacy Test Case C4 failed')
@@ -393,6 +414,7 @@ class Test(unittest.TestCase):
'trsvcid': '8009',
'subsysnqn': 'hello',
'host-iface': ifname,
+ 'host-nqn': '',
}
)
self.assertEqual(True, udev.UDEV._cid_matches_tid(tid, cid_legacy), msg=f'Legacy Test Case D4 failed')
@@ -405,6 +427,7 @@ class Test(unittest.TestCase):
'host-traddr': '',
'host-iface': ifname,
'src-addr': '', # Legacy
+ 'host-nqn': '',
}
tid = trid.TID(
{
@@ -414,6 +437,7 @@ class Test(unittest.TestCase):
'subsysnqn': 'hello',
'host-traddr': '1.1.1.1',
'host-iface': 'blah',
+ 'host-nqn': '',
}
)
self.assertEqual(False, udev.UDEV._cid_matches_tid(tid, cid_legacy), msg=f'Legacy Test Case E4 failed')
@@ -425,6 +449,7 @@ class Test(unittest.TestCase):
'trsvcid': '8009',
'subsysnqn': 'hello',
'host-traddr': '1.1.1.1',
+ 'host-nqn': '',
}
)
self.assertEqual(False, udev.UDEV._cid_matches_tid(tid, cid_legacy), msg=f'Legacy Test Case F4 failed')
@@ -436,6 +461,7 @@ class Test(unittest.TestCase):
'trsvcid': '8009',
'subsysnqn': 'hello',
'host-traddr': ipv4_addrs[0],
+ 'host-nqn': '',
}
)
match = len(ipv4_addrs) == 1 and iputil.get_ipaddress_obj(
@@ -456,6 +482,7 @@ class Test(unittest.TestCase):
'host-traddr': src_ipv6,
'host-iface': ifname,
'src-addr': src_ipv6,
+ 'host-nqn': '',
}
cid_legacy = {
'transport': 'tcp',
@@ -465,6 +492,7 @@ class Test(unittest.TestCase):
'host-traddr': src_ipv6,
'host-iface': ifname,
'src-addr': '', # Legacy
+ 'host-nqn': '',
}
for case_id, tid, match in get_tids_to_test(6, src_ipv6, ifname):
self.assertEqual(match, udev.UDEV._cid_matches_tid(tid, cid), msg=f'Test Case {case_id} failed')
@@ -480,6 +508,7 @@ class Test(unittest.TestCase):
'host-traddr': '',
'host-iface': '',
'src-addr': '', # Legacy
+ 'host-nqn': '',
}
tid = trid.TID(
{
@@ -488,6 +517,7 @@ class Test(unittest.TestCase):
'trsvcid': '8009',
'subsysnqn': 'hello',
'host-traddr': 'AAAA::FFFF',
+ 'host-nqn': '',
}
)
self.assertEqual(True, udev.UDEV._cid_matches_tid(tid, cid_legacy), msg=f'Legacy Test Case A6.1 failed')
@@ -500,6 +530,7 @@ class Test(unittest.TestCase):
'host-traddr': '',
'host-iface': ifname,
'src-addr': '', # Legacy
+ 'host-nqn': '',
}
tid = trid.TID(
{
@@ -507,6 +538,7 @@ class Test(unittest.TestCase):
'traddr': traddr(6),
'trsvcid': '8009',
'subsysnqn': 'hello',
+ 'host-nqn': '',
}
)
self.assertEqual(True, udev.UDEV._cid_matches_tid(tid, cid_legacy), msg=f'Legacy Test Case A6.2 failed')
@@ -522,6 +554,7 @@ class Test(unittest.TestCase):
'host-traddr': src_ipv6,
'host-iface': '',
'src-addr': '', # Legacy
+ 'host-nqn': '',
}
tid = trid.TID(
{
@@ -530,6 +563,7 @@ class Test(unittest.TestCase):
'trsvcid': '8009',
'subsysnqn': 'hello',
'host-traddr': 'AAAA::FFFF',
+ 'host-nqn': '',
}
)
self.assertEqual(False, udev.UDEV._cid_matches_tid(tid, cid_legacy), msg=f'Legacy Test Case B6 failed')
@@ -541,6 +575,7 @@ class Test(unittest.TestCase):
'trsvcid': '8009',
'subsysnqn': 'hello',
'host-iface': 'blah',
+ 'host-nqn': '',
}
)
self.assertEqual(False, udev.UDEV._cid_matches_tid(tid, cid_legacy), msg=f'Legacy Test Case C6 failed')
@@ -552,6 +587,7 @@ class Test(unittest.TestCase):
'trsvcid': '8009',
'subsysnqn': 'hello',
'host-iface': ifname,
+ 'host-nqn': '',
}
)
self.assertEqual(True, udev.UDEV._cid_matches_tid(tid, cid_legacy), msg=f'Legacy Test Case D6 failed')
@@ -564,6 +600,7 @@ class Test(unittest.TestCase):
'host-traddr': '',
'host-iface': ifname,
'src-addr': '', # Legacy
+ 'host-nqn': '',
}
tid = trid.TID(
{
@@ -573,6 +610,7 @@ class Test(unittest.TestCase):
'subsysnqn': 'hello',
'host-traddr': 'AAA::BBBB',
'host-iface': 'blah',
+ 'host-nqn': '',
}
)
self.assertEqual(False, udev.UDEV._cid_matches_tid(tid, cid_legacy), msg=f'Legacy Test Case E6 failed')
@@ -584,6 +622,7 @@ class Test(unittest.TestCase):
'trsvcid': '8009',
'subsysnqn': 'hello',
'host-traddr': 'AAA::BBB',
+ 'host-nqn': '',
}
)
self.assertEqual(False, udev.UDEV._cid_matches_tid(tid, cid_legacy), msg=f'Legacy Test Case F6 failed')
@@ -595,6 +634,7 @@ class Test(unittest.TestCase):
'trsvcid': '8009',
'subsysnqn': 'hello',
'host-traddr': ipv6_addrs[0],
+ 'host-nqn': '',
}
)
match = len(ipv6_addrs) == 1 and iputil.get_ipaddress_obj(
@@ -612,6 +652,7 @@ class Test(unittest.TestCase):
'host-traddr': 'AAA::BBBB',
'host-iface': '',
'src-addr': '',
+ 'host-nqn': '',
}
tid = trid.TID(
{
@@ -620,6 +661,7 @@ class Test(unittest.TestCase):
'trsvcid': '',
'subsysnqn': 'hello',
'host-traddr': 'AAA::BBBB',
+ 'host-nqn': '',
}
)
self.assertEqual(True, udev.UDEV._cid_matches_tid(tid, cid), msg=f'Test Case FC-1 failed')
@@ -631,6 +673,7 @@ class Test(unittest.TestCase):
'trsvcid': '',
'subsysnqn': 'hello',
'host-traddr': 'BBBB::AAA',
+ 'host-nqn': '',
}
)
self.assertEqual(False, udev.UDEV._cid_matches_tid(tid, cid), msg=f'Test Case FC-2 failed')
@@ -645,6 +688,7 @@ class Test(unittest.TestCase):
'host-traddr': '5.4.3.2',
'host-iface': '',
'src-addr': '',
+ 'host-nqn': '',
}
tid = trid.TID(
{
@@ -653,6 +697,7 @@ class Test(unittest.TestCase):
'trsvcid': '4444',
'subsysnqn': 'hello',
'host-traddr': '5.4.3.2',
+ 'host-nqn': '',
}
)
self.assertEqual(True, udev.UDEV._cid_matches_tid(tid, cid), msg=f'Test Case RDMA-1 failed')
@@ -664,6 +709,7 @@ class Test(unittest.TestCase):
'trsvcid': '4444',
'subsysnqn': 'hello',
'host-traddr': '5.5.6.6',
+ 'host-nqn': '',
}
)
self.assertEqual(False, udev.UDEV._cid_matches_tid(tid, cid), msg=f'Test Case RDMA-2 failed')
@@ -674,6 +720,7 @@ class Test(unittest.TestCase):
'traddr': '2.3.4.5',
'trsvcid': '4444',
'subsysnqn': 'hello',
+ 'host-nqn': '',
}
)
self.assertEqual(True, udev.UDEV._cid_matches_tid(tid, cid), msg=f'Test Case RDMA-3 failed')