@@ -31,6 +31,7 @@ class TestValid(unittest.TestCase):
31
31
32
32
def test_null_with_segment (self ):
33
33
34
+ assert PCI .is_valid ("0000:00:00.0" ) is True
34
35
c = PCI ("0000:00:00.0" )
35
36
36
37
self .assertEqual (c .segment , 0 )
@@ -43,6 +44,7 @@ def test_null_with_segment(self):
43
44
44
45
def test_null_without_segment (self ):
45
46
47
+ assert PCI .is_valid ("00:00.0" ) is True
46
48
c = PCI ("00:00.0" )
47
49
48
50
self .assertEqual (c .segment , 0 )
@@ -54,13 +56,26 @@ def test_null_without_segment(self):
54
56
55
57
def test_valid (self ):
56
58
59
+ assert PCI .is_valid ("8765:43:1f.3" ) is True
57
60
c = PCI ("8765:43:1f.3" )
58
61
59
62
self .assertEqual (c .segment , 0x8765 )
60
63
self .assertEqual (c .bus , 0x43 )
61
64
self .assertEqual (c .device , 0x1f )
62
65
self .assertEqual (c .function , 0x3 )
63
66
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
+
64
79
def test_equality (self ):
65
80
66
81
self .assertEqual (PCI ("0000:00:00.0" ), PCI ("00:00.0" ))
0 commit comments