Esempio n. 1
0
class TestDrvinfo(TestCaseBase):
    _bridge = tcTests._Bridge()
    _unicode_bridge = tcTests._Bridge()

    @ValidateRunningAsRoot
    def setUp(self):
        tcTests._checkDependencies()
        self._bridge.addDevice()
        self._unicode_bridge.devName = 'test-トトロ'
        self._unicode_bridge.addDevice()

    def tearDown(self):
        self._bridge.delDevice()
        self._unicode_bridge.delDevice()

    def testBridgeEthtoolDrvinfo(self):
        self.assertEqual(ipwrapper.drv_name(self._bridge.devName),
                         ipwrapper.LinkType.BRIDGE)

    def testUtf8BridgeEthtoolDrvinfo(self):
        self.assertEqual(
            ipwrapper.drv_name(self._unicode_bridge.devName.decode('utf8')),
            ipwrapper.LinkType.BRIDGE)

    def testTogglePromisc(self):
        ipwrapper.getLink(self._bridge.devName).promisc = True
        self.assertTrue(
            ipwrapper.getLink(self._bridge.devName).promisc,
            "Could not enable promiscuous mode.")

        ipwrapper.getLink(self._bridge.devName).promisc = False
        self.assertFalse(
            ipwrapper.getLink(self._bridge.devName).promisc,
            "Could not disable promiscuous mode.")
Esempio n. 2
0
class TestDrvinfo(TestCaseBase):
    _bridge = tcTests._Bridge()

    @ValidateRunningAsRoot
    def setUp(self):
        tcTests._checkDependencies()
        self._bridge.addDevice()

    def tearDown(self):
        self._bridge.delDevice()

    def testBridgeEthtoolDrvinfo(self):
        self.assertEqual(ipwrapper.drv_name(self._bridge.devName),
                         ipwrapper.LinkType.BRIDGE)
Esempio n. 3
0
class TestLinks(TestCaseBase):
    _bridge = tcTests._Bridge()

    @ValidateRunningAsRoot
    def setUp(self):
        tcTests._checkDependencies()
        self._bridge.addDevice()

    def tearDown(self):
        self._bridge.delDevice()

    def testGetLink(self):
        link = ipwrapper.getLink(self._bridge.devName)
        self.assertTrue(link.isBRIDGE)
        self.assertEqual(link.master, None)
        self.assertEqual(link.name, self._bridge.devName)
Esempio n. 4
0
class TestBridgeOverwrite(TestCaseBase):
    _bridge = _Bridge()

    @ValidateRunningAsRoot
    def setUp(self):
        _checkDependencies()
        self._bridge.addDevice()

    def tearDown(self):
        self._bridge.delDevice()

    def testBridgeOverwriteErr(self):
        """iproute2 configurator uses hardcoded error output, test it's still
        the same"""
        expected_err = _BRCTL_DEV_EXISTS % self._bridge.devName
        popen = Popen([EXT_BRCTL, 'addbr', self._bridge.devName], stderr=PIPE)
        err = popen.stderr.read().strip()
        self.assertEquals(expected_err, err)
Esempio n. 5
0
    def testMonitorIteration(self):
        bridge = tcTests._Bridge()
        tcTests._checkDependencies()
        mon = Monitor()
        mon.start()
        iterator = iter(mon)

        bridge.addDevice()  # Generate an event to avoid blocking
        iterator.next()

        bridge.delDevice()
        iterator.next()  # Generate an event to avoid blocking

        # Stop the monitor and check that eventually StopIteration is raised.
        # There might be other system link events so we loop to exhaust them.
        mon.stop()
        with self.assertRaises(StopIteration):
            while True:
                iterator.next()
Esempio n. 6
0
    def testMonitorIteration(self):
        bridge = tcTests._Bridge()
        tcTests._checkDependencies()
        mon = Monitor()
        mon.start()
        iterator = iter(mon)

        bridge.addDevice()  # Generate an event to avoid blocking
        iterator.next()

        bridge.delDevice()
        iterator.next()  # Generate an event to avoid blocking

        # Stop the monitor and check that eventually StopIteration is raised.
        # There might be other system link events so we loop to exhaust them.
        mon.stop()
        with self.assertRaises(StopIteration):
            while True:
                iterator.next()