Ejemplo n.º 1
0
def test_ethtool_S_f():
    ethtool_S_info_f1 = ethtool.Statistics(context_wrap(FAILED_ETHTOOL_S_ONE))
    assert not ethtool_S_info_f1.ifname
    ethtool_S_info_f2 = ethtool.Statistics(context_wrap(FAILED_ETHTOOL_S_TWO))
    assert not ethtool_S_info_f2.ifname
    ethtool_S_info_f2 = ethtool.Statistics(context_wrap(FAILED_ETHTOOL_S_THREE))
    assert not ethtool_S_info_f2.ifname
Ejemplo n.º 2
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.º 3
0
def test_ethtool_S_subinterface():
    ethtool_S_info = ethtool.Statistics(context_wrap(ETHTOOL_S_eth0_1))
    assert sorted(ethtool_S_info.data.keys()) == sorted([
        'rxq0: rx_pkts', 'rxq0: rx_drops_no_frags', 'rxq1: rx_pkts',
        'rxq1: rx_drops_no_frags'
    ])
    assert ethtool_S_info.data['rxq0: rx_pkts'] == 5000000
Ejemplo n.º 4
0
def test_ethtool_S():
    ethtool_S_info = ethtool.Statistics(context_wrap(SUCCEED_ETHTOOL_S))
    ret = {}
    for line in SUCCEED_ETHTOOL_S.split('\n')[2:-1]:
        key, value = line.split(':')
        ret[key.strip()] = int(value.strip()) if value else None
    eth_data = dict(ethtool_S_info.data)
    assert eth_data == ret

    # Test search functionality
    assert ethtool_S_info.search(r'rx_queue_3') == {
        'rx_queue_3_packets': 0,
        'rx_queue_3_bytes': 0,
        'rx_queue_3_drops': 0,
        'rx_queue_3_csum_err': 0,
        'rx_queue_3_alloc_failed': 0,
    }
    assert ethtool_S_info.search(r'RX_QUEUE_3', flags=re.IGNORECASE) == {
        'rx_queue_3_packets': 0,
        'rx_queue_3_bytes': 0,
        'rx_queue_3_drops': 0,
        'rx_queue_3_csum_err': 0,
        'rx_queue_3_alloc_failed': 0,
    }