Skip to content

Commit 270ccd1

Browse files
Add testcases for PCI.is_valid()
Signed-off-by: Bernhard Kaindl <[email protected]>
1 parent 855cb9b commit 270ccd1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/test_pci.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class TestValid(unittest.TestCase):
3131

3232
def test_null_with_segment(self):
3333

34+
assert PCI.is_valid("0000:00:00.0") is True
3435
c = PCI("0000:00:00.0")
3536

3637
self.assertEqual(c.segment, 0)
@@ -43,6 +44,7 @@ def test_null_with_segment(self):
4344

4445
def test_null_without_segment(self):
4546

47+
assert PCI.is_valid("00:00.0") is True
4648
c = PCI("00:00.0")
4749

4850
self.assertEqual(c.segment, 0)
@@ -54,13 +56,26 @@ def test_null_without_segment(self):
5456

5557
def test_valid(self):
5658

59+
assert PCI.is_valid("8765:43:1f.3") is True
5760
c = PCI("8765:43:1f.3")
5861

5962
self.assertEqual(c.segment, 0x8765)
6063
self.assertEqual(c.bus, 0x43)
6164
self.assertEqual(c.device, 0x1f)
6265
self.assertEqual(c.function, 0x3)
6366

67+
def test_valid_index(self):
68+
69+
assert PCI.is_valid("8765:43:1f.3[0]") is True
70+
assert PCI.is_valid("1234:56:01.7[1]") is True
71+
c = PCI("1234:56:01.7[1]")
72+
73+
self.assertEqual(c.segment, 0x1234)
74+
self.assertEqual(c.bus, 0x56)
75+
self.assertEqual(c.device, 0x01)
76+
self.assertEqual(c.function, 0x7)
77+
self.assertEqual(c.index, 0x1)
78+
6479
def test_equality(self):
6580

6681
self.assertEqual(PCI("0000:00:00.0"), PCI("00:00.0"))

0 commit comments

Comments
 (0)