Ejemplo n.º 1
0
def test_ethtool_fail():
    with pytest.raises(ParseException):
        ethtool.Ethtool(context_wrap(FAIL_ETHTOOL_A_1, path="ethtool_eth1"))
    with pytest.raises(ParseException) as e:
        ethtool.Ethtool(context_wrap(ETHTOOL_INFO_BAD_1, path="ethtool_eth1"))
    assert "Fake ethnic as ethtool command argument" in str(e.value)

    with pytest.raises(ParseException) as e:
        ethtool.Ethtool(context_wrap(ETHTOOL_INFO_BAD_2, path="ethtool_eth1"))
    assert "ethtool: unrecognised first line " in str(e.value)

    with pytest.raises(ParseException) as e:
        ethtool.Ethtool(context_wrap(ETHTOOL_INFO_BAD_3, path="ethtool_eth1"))
    assert 'Ethtool unable to parse content' in str(e.value)
Ejemplo n.º 2
0
def test_ethtool_fail():
    with pytest.raises(ParseException):
        ethtool.Ethtool(context_wrap(FAIL_ETHTOOL_A_1, path="ethtool_eth1"))
    with pytest.raises(ParseException) as e:
        ethtool.Ethtool(context_wrap(ETHTOOL_INFO_BAD_1, path="ethtool_eth1"))
    assert "Fake ethnic as ethtool command argument" in str(e.value)

    with pytest.raises(ParseException) as e:
        ethtool.Ethtool(context_wrap(ETHTOOL_INFO_BAD_2, path="ethtool_eth1"))
    assert "Ethtool does not contain Settings for <nic>:" in str(e.value)

    with pytest.raises(ParseException) as e:
        ethtool.Ethtool(context_wrap(ETHTOOL_INFO_BAD_3, path="ethtool_eth1"))
    assert 'Ethtool unable to parse content' in str(e.value)
Ejemplo n.º 3
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
Ejemplo n.º 4
0
def test_ethtool():
    ethtool_info = ethtool.Ethtool(
        context_wrap(ETHTOOL_INFO, path="ethtool_eth1"))
    assert ethtool_info.ifname == "eth1"
    assert ethtool_info.link_detected
    assert ethtool_info.speed == ['1000Mb/s']
    assert ethtool_info.supported_link_modes == [
        '10baseT/Half', '10baseT/Full', '100baseT/Half', '100baseT/Full',
        '1000baseT/Full'
    ]
    assert ethtool_info.advertised_link_modes == [
        '10baseT/Half', '10baseT/Full', '100baseT/Half', '100baseT/Full',
        '1000baseT/Full'
    ]
    assert ethtool_info.supported_ports == ['TP', 'MII']
Ejemplo n.º 5
0
def test_ethtool_corner_cases():
    ethtool_info = ethtool.Ethtool(
        context_wrap(ETHTOOL_INFO_TEST, path="ethtool_eth1"))
    assert ethtool_info.ifname == "eth1"