@@ -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,28 +56,47 @@ 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" ))
82+ assert PCI ("1234:56:01.7[1]" ) != PCI ("1234:56:01.7[2]" )
83+ assert PCI ("1234:56:01.2" ) >= PCI ("1234:56:01.2" )
84+ assert PCI ("1234:56:01.1" ) <= PCI ("1234:56:01.2" )
85+ assert PCI ("1234:56:01.3" ) > PCI ("1234:56:01.2" )
86+ assert PCI ("1234:56:01.1" ) < PCI ("1234:56:02.2" )
6787
6888
6989if sys .version_info >= (2 , 7 ):
7090 def assert_videoclass_devices (ids , devs ): # type: (PCIIds, PCIDevices) -> None
71- """Verification function for checking the otuput of PCIDevices.findByClass()"""
91+ """Verification function for checking the output of PCIDevices.findByClass()"""
7292 video_class = ids .lookupClass ('Display controller' )
7393 assert video_class == ["03" ]
7494 sorted_devices = sorted (devs .findByClass (video_class ),
7595 key = lambda x : x ['id' ])
7696
7797 # Assert devs.findByClass() finding 3 GPUs from tests/data/lspci-mn in our mocked PCIIds DB:
7898 assert len (sorted_devices ) == 3
99+ assert len (devs .findByClass ("03" , "80" )) == 2
79100
80101 # For each of the found devices, assert these expected values:
81102 for (video_dev ,
0 commit comments