Ejemplo n.º 1
0
def test_addbr_delete():
    br = brctl.addbr(b'br_test')
    try:
        check_output(b'brctl show', substr=[br.name])
    finally:
        br.delete()
    check_output(b'brctl show', not_substr=[br.name])
Ejemplo n.º 2
0
def test_pause_param_settings(if1, rx, tx):
    if1.set_pause_param(False, rx, tx)
    expected = [
        br'Autonegotiate:\s+off',
        br'RX:\s+' + (b'on' if rx else b'off'),
        br'TX:\s+' + (b'on' if tx else b'off'),
    ]
    check_output(b'ethtool -a ' + if1.name, regex=expected)
Ejemplo n.º 3
0
def test_pause_param_autonegotiate(if1):
    if1.set_pause_param(True, True, True)
    check_output(b'ethtool -a ' + if1.name,
                 regex=[br'Autonegotiate:\s+on'])

    if1.set_pause_param(False, True, True)
    check_output(b'ethtool -a ' + if1.name,
                 regex=[br'Autonegotiate:\s+off'])
Ejemplo n.º 4
0
def test_pause_param_settings(if1, rx, tx):
    if1.set_pause_param(False, rx, tx)
    expected = [
        br'Autonegotiate:\s+off',
        br'RX:\s+' + (b'on' if rx else b'off'),
        br'TX:\s+' + (b'on' if tx else b'off'),
    ]
    check_output(b'ethtool -a ' + if1.name, regex=expected)
Ejemplo n.º 5
0
def test_set_netmask(if1):
    if1.netmask = 16
    assert if1.netmask == 16
    check_output(b'ip addr show ' + if1.name, regex=[br'inet [0-9\.]+/16'])

    if1.netmask = 21
    assert if1.netmask == 21
    check_output(b'ip addr show ' + if1.name, regex=[br'inet [0-9\.]+/21'])
Ejemplo n.º 6
0
def test_up_down(if1):
    if1.down()
    assert not if1.is_up()
    check_output(b'ip link show ' + if1.name,
                 regex=[if1.name + br': <.+>'], not_substr=[b'UP'])
    if1.up()
    assert if1.is_up()
    check_output(b'ip link show ' + if1.name,
                 regex=[if1.name + br': <.+>'], substr=[b'UP'])
Ejemplo n.º 7
0
def test_set_netmask(if1):
    if1.netmask = 16
    assert if1.netmask == 16
    check_output(b'ip addr show ' + if1.name,
                 regex=[br'inet [0-9\.]+/16'])

    if1.netmask = 21
    assert if1.netmask == 21
    check_output(b'ip addr show ' + if1.name,
                 regex=[br'inet [0-9\.]+/21'])
Ejemplo n.º 8
0
def test_set_link_auto(if1, ten, hundred, thousand):
    expected = br'Advertised link modes:\s+'
    if ten:
        expected += br'10baseT/Half 10baseT/Full\s+'
    if hundred:
        expected += br'100baseT/Half 100baseT/Full\s+'
    if thousand:
        expected += br'1000baseT/Full'

    if1.set_link_auto(ten, hundred, thousand)
    check_output(b'ethtool ' + if1.name, regex=[expected])
Ejemplo n.º 9
0
def test_up_down(if1):
    if1.down()
    assert not if1.is_up()
    check_output(b'ip link show ' + if1.name,
                 regex=[if1.name + br': <.+>'],
                 not_substr=[b'UP'])
    if1.up()
    assert if1.is_up()
    check_output(b'ip link show ' + if1.name,
                 regex=[if1.name + br': <.+>'],
                 substr=[b'UP'])
Ejemplo n.º 10
0
def test_set_link_auto(if1, ten, hundred, thousand):
    expected = br'Advertised link modes:\s+'
    if ten:
        expected += br'10baseT/Half 10baseT/Full\s+'
    if hundred:
        expected += br'100baseT/Half 100baseT/Full\s+'
    if thousand:
        expected += br'1000baseT/Full'

    if1.set_link_auto(ten, hundred, thousand)
    check_output(b'ethtool ' + if1.name, regex=[expected])
Ejemplo n.º 11
0
def test_addif(br1):
    cmd = b'brctl show ' + br1.name
    check_output(cmd, not_substr=[b'eth1', b'eth2'])
    br1.addif(b'eth1')
    check_output(cmd, substr=[b'eth1'], not_substr=[b'eth2'])
    br1.addif(b'eth2')
    check_output(cmd, substr=[b'eth1', b'eth2'])
Ejemplo n.º 12
0
def test_set_mac(if1):
    if1.mac = '00:11:22:33:44:55'
    assert if1.mac == '00:11:22:33:44:55'
    check_output(b'ip link show ' + if1.name,
                 substr=[b'link/ether 00:11:22:33:44:55'])
Ejemplo n.º 13
0
def test_set_mac(if1):
    if1.mac = '00:11:22:33:44:55'
    assert if1.mac == '00:11:22:33:44:55'
    check_output(b'ip link show ' + if1.name,
                 substr=[b'link/ether 00:11:22:33:44:55'])
Ejemplo n.º 14
0
def test_pause_param_autonegotiate(if1):
    if1.set_pause_param(True, True, True)
    check_output(b'ethtool -a ' + if1.name, regex=[br'Autonegotiate:\s+on'])

    if1.set_pause_param(False, True, True)
    check_output(b'ethtool -a ' + if1.name, regex=[br'Autonegotiate:\s+off'])
Ejemplo n.º 15
0
def test_delif(br1):
    cmd = b'brctl show ' + br1.name
    br1.addif(b'eth1')
    check_output(cmd, substr=[b'eth1'])
    br1.delif(b'eth1')
    check_output(cmd, not_substr=[b'eth1'])
Ejemplo n.º 16
0
def test_get_index(if1, if2):
    for i in [if1, if2]:
        idx = str(i.index).encode('ascii')
        check_output(b'ip link show ' + i.name,
                     substr=[idx + b': ' + i.name + b':'])
Ejemplo n.º 17
0
def test_get_index(if1, if2):
    for i in [if1, if2]:
        idx = str(i.index).encode('ascii')
        check_output(b'ip link show ' + i.name,
                     substr=[idx + b': ' + i.name + b':'])
Ejemplo n.º 18
0
def test_set_forward_delay(br1):
    for value in [50, 100, 1000]:
        br1.set_forward_delay(value)
        check_output(b'brctl showstp ' + br1.name,
                     regex=[br'forward delay\s+' + str(value).encode('ascii')])