예제 #1
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
예제 #2
0
def test_lspci_vmmkn():
    lspci_vmmkn = LsPciVmmkn(context_wrap(LSPCI_VMMKN))
    assert sorted(lspci_vmmkn.pci_dev_list) == ['00:00.0', '00:01.0', '00:01.1', '00:03.0']
    assert lspci_vmmkn[0].get('Driver') is None
    assert lspci_vmmkn[1].get('Vendor') == '8086'
    assert lspci_vmmkn[1].get('Device') == '7010'
    assert lspci_vmmkn[2].get('SVendor') == '1af4'
    assert lspci_vmmkn[3].get('SDevice') == '0001'
    assert lspci_vmmkn[-1].get('Driver') == 'virtio-pci'
    assert sorted(lspci_vmmkn[1].get('Module')) == sorted(['ata_piix', 'ata_generic'])
    assert lspci_vmmkn[-1].get('Module') is None
예제 #3
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)'
    }]
예제 #4
0
def test_lspci_vmmkn():
    lspci_vmmkn = LsPciVmmkn(context_wrap(LSPCI_VMMKN))
    lspci = LsPci(None, 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(Device='155a', Vendor='8086') == [{
        'Slot': '00:19.0',
        'Class': '0200',
        'Vendor': '8086',
        'Device': '155a',
        'SVendor': '17aa',
        'SDevice': '2214',
        'Rev': '04',
        'Driver': 'e1000e',
        'Module': ['e1000e'],
    }]
    assert lspci.search(Dev_Details__contains='I218') == []
예제 #5
0
def test_lspci_vmmkn_ab():
    with pytest.raises(SkipException):
        LsPciVmmkn(context_wrap(''))

    with pytest.raises(SkipException):
        LsPciVmmkn(context_wrap(' \n '.splitlines()))
예제 #6
0
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
예제 #7
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'
    ])
예제 #8
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'
    ])