From: Vincent Bernat Date: Fri, 15 Sep 2017 21:20:28 +0000 (+0200) Subject: tests: fix previous testcase to fail without previous commit X-Git-Tag: 0.9.9~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=69594747984ae7ef2d7cc05528e1edee6e2e7fba;p=thirdparty%2Flldpd.git tests: fix previous testcase to fail without previous commit Only the bridge ioctl can trigger this bug. --- diff --git a/tests/integration/fixtures/network.py b/tests/integration/fixtures/network.py index 87d1610d..aa2a85c3 100644 --- a/tests/integration/fixtures/network.py +++ b/tests/integration/fixtures/network.py @@ -1,6 +1,8 @@ import pytest import pyroute2 import struct +import socket +import fcntl import time from .namespaces import Namespace @@ -134,10 +136,15 @@ class LinksFactory(object): idx = ipr.link_lookup(ifname=name)[0] ipr.link('del', index=idx) - def nomaster(self, name): + def unbridge(self, bridgename, name): ipr = pyroute2.IPRoute() idx = ipr.link_lookup(ifname=name)[0] - ipr.link('set', index=idx, master=0) + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0) + ifr = struct.pack("16si", b"br42", idx) + fcntl.ioctl(s, + 0x89a3, # SIOCBRDELIF + ifr) + s.close() @pytest.fixture diff --git a/tests/integration/test_interfaces.py b/tests/integration/test_interfaces.py index 9788f6e8..22cb0792 100644 --- a/tests/integration/test_interfaces.py +++ b/tests/integration/test_interfaces.py @@ -27,8 +27,10 @@ def test_remove_bridge(lldpd, lldpcli, namespaces, links): with namespaces(1): out = lldpcli("-f", "keyvalue", "show", "neighbors", "details") assert out['lldp.eth0.port.descr'] == 'eth1' - # Remove from bridge - links.nomaster('eth0') + # Remove from bridge. We don't use netlink because we wouldn't + # get the wanted effect: we also get a RTM_NEWLINK by doing + # that. Only the bridge ioctl() would prevent that. + links.unbridge('br42', 'eth0') time.sleep(1) # Check if we still have eth0 out = lldpcli("-f", "keyvalue", "show", "neighbors", "details")