Пример #1
0
def test_lspci():
    lspci_0 = LsPci(context_wrap(LSPCI_0))
    assert [i['raw_message'] for i in lspci_0.get("Intel Corporation")] == INTEL.splitlines()
    assert len(lspci_0.get("Network controller")) == 1
    assert "Centrino Advanced-N 6205" in lspci_0
    assert "0d:00.0" in lspci_0
    other = LsPci(context_wrap(OTHER))
    assert [i['raw_message'] for i in other.get("Renesas Technology Corp.")] == RENESAS.splitlines()
    assert len(other.get("Xeon E5 v3")) == 4
    assert len(other.get("001a")) == 1
    assert "Core i7" in other
Пример #2
0
def test_doc_examples():
    env = {
            'lspci': LsPci(context_wrap(LSPCI_DRIVER_DOC)),
            'lspci_vmmkn': LsPciVmmkn(context_wrap(LSPCI_VMMKN))
          }
    failed, total = doctest.testmod(lspci, globs=env)
    assert failed == 0
Пример #3
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'
Пример #4
0
def test_lspci_driver():
    lspci_obj = LsPci(context_wrap(LSPCI_DRIVER_DETAILS))
    assert len(lspci_obj.data) == 44
    dev_info = lspci_obj.pci_dev_details('00:01.0')
    assert len(dev_info) == 3
    assert dev_info['Kernel driver in use'] == 'pcieport'
    assert len(lspci_obj.pci_dev_list) == 44

    lspci_obj = LsPci(context_wrap(LSPCI_DRIVER_DETAILS_2))
    assert len(lspci_obj.data) == 4
    dev_info = lspci_obj.pci_dev_details('04:00.0')
    assert len(dev_info) == 1
    assert 'Kernel driver in use' not in dev_info
    assert len(lspci_obj.pci_dev_list) == 4

    lspci_obj = LsPci(context_wrap(LSPCI_DRIVER_DETAILS_3))
    assert len(lspci_obj.data) == 0
    assert len(lspci_obj.pci_dev_list) == 0
Пример #5
0
def test_lspci_driver():
    lspci_obj = LsPci(context_wrap(LSPCI_DRIVER_DETAILS))
    assert len(lspci_obj.data) == 44
    dev_info = lspci_obj.pci_dev_details('00:01.0')
    assert len(dev_info) == 4
    assert dev_info['Kernel driver in use'] == 'pcieport'
    assert dev_info['Slot'] == '00:01.0'
    assert len(lspci_obj.pci_dev_list) == 44

    lspci_obj = LsPci(context_wrap(LSPCI_DRIVER_DETAILS_2))
    assert len(lspci_obj.data) == 4
    dev_info = lspci_obj.pci_dev_details('04:00.0')
    assert len(dev_info) == 2
    assert dev_info['Slot'] == '04:00.0'
    assert 'Kernel driver in use' not in dev_info
    assert len(lspci_obj.pci_dev_list) == 4

    lspci_obj = LsPci(context_wrap(LSPCI_DRIVER_DETAILS_3))
    assert len(lspci_obj.data) == 0
    assert len(lspci_obj.pci_dev_list) == 0

    output = LsPci(context_wrap(LSPCI_OUTPUT_WITH_BAD_LINES))
    assert len(output.data) == 1
    assert len(output.pci_dev_list) == 1
Пример #6
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'
    ])
Пример #7
0
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'
    ])