def test_lspci_both(): lspci_vmmkn = LsPciVmmkn(context_wrap(LSPCI_VMMKN)) lspci_k = LsPciParser(context_wrap(LSPCI_K)) lspci = LsPci(lspci_k, lspci_vmmkn) assert sorted(lspci.pci_dev_list) == [ '00:00.0', '00:02.0', '00:03.0', '00:16.0', '00:19.0', '00:1b.0' ] assert lspci.search(Dev_Details__contains='I218') == [{ 'Slot': '00:19.0', 'Class': '0200', 'Vendor': '8086', 'Device': '155a', 'SVendor': '17aa', 'SDevice': '2214', 'Rev': '04', 'Driver': 'e1000e', 'Module': ['e1000e'], 'Subsystem': 'Lenovo ThinkPad X240', 'Dev_Details': 'Ethernet controller: Intel Corporation Ethernet Connection I218-LM (rev 04)' }] assert lspci.search(Slot='00:1b.0') == [{ 'Slot': '00:1b.0', 'Class': '0403', 'Vendor': '8086', 'Device': '9c20', 'SVendor': '17aa', 'SDevice': '2214', 'Rev': '04', 'Driver': 'snd_hda_intel', 'Module': ['snd_hda_intel'], 'Subsystem': 'Lenovo ThinkPad X240', 'Dev_Details': 'Audio device: Intel Corporation 8 Series HD Audio Controller (rev 04)' }]
def test_lspci_k(): lspci_k = LsPciParser(context_wrap(LSPCI_K)) lspci = LsPci(lspci_k, None) assert sorted(lspci.pci_dev_list) == [ '00:00.0', '00:02.0', '00:03.0', '00:16.0', '00:19.0', '00:1b.0' ] assert lspci.search(Dev_Details__contains='I218') == [{ 'Driver': 'e1000e', 'Module': ['e1000e'], 'Subsystem': 'Lenovo ThinkPad X240', 'Dev_Details': 'Ethernet controller: Intel Corporation Ethernet Connection I218-LM (rev 04)' }] assert lspci.search(Slot__startwith='00:1b.0') == []
def test_lspci_k(): lspci_k = LsPciParser(context_wrap(LSPCI_K)) lspci = LsPci(lspci_k, None) assert sorted(lspci.pci_dev_list) == [ '00:00.0', '00:02.0', '00:03.0', '00:16.0', '00:19.0', '00:1b.0' ] assert lspci.search(Dev_Details__contains='I218') == [{ 'Slot': '00:19.0', 'Driver': 'e1000e', 'Module': ['e1000e'], 'Subsystem': 'Lenovo ThinkPad X240', 'Dev_Details': 'Ethernet controller: Intel Corporation Ethernet Connection I218-LM (rev 04)' }] assert lspci.search(Slot__startwith='00:1b.0') == [] # Make sure the original parser is untouched assert lspci_k.pci_dev_details('00:00.0').get( 'Kernel driver in use') == 'hsw_uncore' assert lspci_k.pci_dev_details('00:1b.0').get( 'Kernel driver in use') == 'snd_hda_intel'
def test_doc_examples(): lspci_vmmkn = LsPciVmmkn(context_wrap(LSPCI_VMMKN)) lspci_k = LsPciParser(context_wrap(LSPCI_K)) env = {'lspci': LsPci(lspci_k, lspci_vmmkn)} failed, total = doctest.testmod(lspci, globs=env) assert failed == 0
def test_lspci_both_long_slot(): lspci_vmmkn = LsPciVmmkn(context_wrap(LSPCI_VMMKN_LONG_SLOT)) lspci_k = LsPciParser(context_wrap(LSPCI_K_LONG_SLOT)) lspci = LsPci(lspci_k, lspci_vmmkn) assert sorted(lspci.pci_dev_list) == [ '0000:00:00.0', '0000:00:07.0', '0000:00:07.1', '0000:00:07.3', '0000:00:08.0', '1a06:00:02.0' ] assert lspci.search(Dev_Details__contains='PIIX4 ISA') == [{ 'Slot': '0000:00:07.0', 'Class': '0601', 'Vendor': '8086', 'Device': '7110', 'SVendor': '1414', 'SDevice': '0000', 'Rev': '01', 'Subsystem': 'Microsoft Corporation Device 0000', 'Dev_Details': 'ISA bridge: Intel Corporation 82371AB/EB/MB PIIX4 ISA (rev 01)' }] assert lspci.search(Slot='1a06:00:02.0') == [{ 'Slot': '1a06:00:02.0', 'Class': '0200', 'Vendor': '15b3', 'Device': '1016', 'SVendor': '15b3', 'SDevice': '0190', 'Rev': '80', 'Driver': 'mlx5_core', 'PhySlot': '1', 'Module': ['mlx5_core'], 'NUMANode': '0', 'Subsystem': 'Mellanox Technologies Device 0190', 'Dev_Details': 'Ethernet controller: Mellanox Technologies MT27710 Family [ConnectX-4 Lx Virtual Function] (rev 80)' }] # Make sure the original parsers are untouched assert sorted(lspci_k.pci_dev_list) == [ '0000:00:00.0', '0000:00:07.0', '0000:00:07.1', '0000:00:07.3', '0000:00:08.0', '1a06:00:02.0' ] assert lspci_k.pci_dev_details('0000:00:00.0').get('Module') is None assert lspci_k.pci_dev_details('0000:00:08.0').get( 'Kernel driver in use') == 'hyperv_fb' assert sorted(lspci_vmmkn.pci_dev_list) == [ '00:00.0', '00:07.0', '00:07.1', '00:07.3', '00:08.0', '1a06:00:02.0' ] assert sorted(lspci_vmmkn[0].keys()) == sorted( ['Class', 'Device', 'Rev', 'Slot', 'Vendor']) assert sorted(lspci_vmmkn[-1].keys()) == sorted([ 'Class', 'Device', 'Driver', 'Module', 'Rev', 'SDevice', 'SVendor', 'Slot', 'Vendor', 'PhySlot', 'NUMANode' ])
def test_lspci_both(): lspci_vmmkn = LsPciVmmkn(context_wrap(LSPCI_VMMKN)) lspci_k = LsPciParser(context_wrap(LSPCI_K)) lspci = LsPci(lspci_k, lspci_vmmkn) assert sorted(lspci.pci_dev_list) == [ '00:00.0', '00:02.0', '00:03.0', '00:16.0', '00:19.0', '00:1b.0' ] assert lspci.search(Dev_Details__contains='I218') == [{ 'Slot': '00:19.0', 'Class': '0200', 'Vendor': '8086', 'Device': '155a', 'SVendor': '17aa', 'SDevice': '2214', 'Rev': '04', 'Driver': 'e1000e', 'Module': ['e1000e'], 'Subsystem': 'Lenovo ThinkPad X240', 'Dev_Details': 'Ethernet controller: Intel Corporation Ethernet Connection I218-LM (rev 04)' }] assert lspci.search(Slot='00:1b.0') == [{ 'Slot': '00:1b.0', 'Class': '0403', 'Vendor': '8086', 'Device': '9c20', 'SVendor': '17aa', 'SDevice': '2214', 'Rev': '04', 'Driver': 'snd_hda_intel', 'Module': ['snd_hda_intel'], 'Subsystem': 'Lenovo ThinkPad X240', 'Dev_Details': 'Audio device: Intel Corporation 8 Series HD Audio Controller (rev 04)' }] # Make sure the original parsers are untouched assert lspci_k.pci_dev_details('00:00.0').get( 'Kernel driver in use') == 'hsw_uncore' assert lspci_k.pci_dev_details('00:1b.0').get( 'Kernel driver in use') == 'snd_hda_intel' assert sorted(lspci_vmmkn[0].keys()) == sorted([ 'Slot', 'Class', 'Vendor', 'Device', 'SVendor', 'SDevice', 'Rev', 'Driver' ]) assert sorted(lspci_vmmkn[-1].keys()) == sorted([ 'Class', 'Device', 'Driver', 'Module', 'Rev', 'SDevice', 'SVendor', 'Slot', 'Vendor' ])