Пример #1
0
def test_ethtool_i_doc_examples():
    env = {
        'coalesce': [
            ethtool.CoalescingInfo(
                context_wrap(TEST_ETHTOOL_C_DOCS, path='ethtool_-c_eth0'))
        ],
        'interfaces': [
            ethtool.Driver(
                context_wrap(TEST_ETHTOOL_I_DOCS, path='ethtool_-i_bond0'))
        ],
        'ethers': [
            ethtool.Ethtool(
                context_wrap(TEST_ETHTOOL_DOCS, path='ethtool_eth0'))
        ],
        'features': [
            ethtool.Features(
                context_wrap(ETHTOOL_K_STANDARD, path='ethtool_-k_bond0'))
        ],
        'pause': [
            ethtool.Pause(
                context_wrap(TEST_ETHTOOL_A_DOCS, path='ethtool_-a_eth0'))
        ],
        'ring': [
            ethtool.Ring(
                context_wrap(TEST_ETHTOOL_G_DOCS, path='ethtool_-g_eth0'))
        ],
        'stats': [
            ethtool.Statistics(
                context_wrap(TEST_ETHTOOL_S_DOCS, path='ethtool_-S_eth0'))
        ],
    }
    failed, total = doctest.testmod(ethtool, globs=env)
    assert failed == 0
Пример #2
0
def test_good():
    context = context_wrap(TEST_ETHTOOL_I_GOOD)
    parsed = ethtool.Driver(context)
    assert parsed.version == "1.0.0"
    assert parsed.driver == 'virtio_net'
    assert parsed.firmware_version is None
    assert parsed.bus_info == '0000:00:03.0'
    assert not parsed.supports_statistics
    assert not parsed.supports_test
    assert not parsed.supports_eeprom_access
    assert not parsed.supports_register_dump
    assert not parsed.supports_priv_flags
Пример #3
0
def test_no_iface():
    context = context_wrap(TEST_ETHTOOL_I_GOOD, path="foo/bar/baz/oopsie")
    parsed = ethtool.Driver(context)
    assert parsed.ifname is None
Пример #4
0
def test_iface():
    context = context_wrap(TEST_ETHTOOL_I_GOOD, path="sbin/ethtool_-i_eth0")
    parsed = ethtool.Driver(context)
    assert parsed.ifname == "eth0"
Пример #5
0
def test_missing_value():
    context = context_wrap(TEST_ETHTOOL_I_GOOD)
    parsed = ethtool.Driver(context)
    assert parsed.firmware_version is None
Пример #6
0
def test_missing_version():
    context = context_wrap(TEST_ETHTOOL_I_MISSING_KEYS)
    parsed = ethtool.Driver(context)
    assert parsed.version is None