Commit de652f18 authored by Martín Ferrari's avatar Martín Ferrari

some test cases for Link

parent e1e4bd7d
#!/usr/bin/env python
# vim:ts=4:sw=4:et:ai:sts=4
import os, unittest
import netns, test_util
class TestGlobal(unittest.TestCase):
@test_util.skipUnless(os.getuid() == 0, "Test requires root privileges")
def test_link(self):
n1 = netns.Node()
n2 = netns.Node()
i1 = n1.add_if()
i2 = n2.add_if()
l = netns.Link()
l.connect(i1)
l.connect(i2)
l.mtu = 3000
ifdata = netns.iproute.get_if_data()[0]
self.assertEquals(ifdata[l.index].mtu, 3000)
self.assertEquals(ifdata[i1.control.index].mtu, 3000, "MTU propagation")
self.assertEquals(ifdata[i2.control.index].mtu, 3000, "MTU propagation")
i1.mtu = i2.mtu = 3000
self.assertEquals(ifdata[l.index].up, False)
self.assertEquals(ifdata[i1.control.index].up, False, "UP propagation")
self.assertEquals(ifdata[i2.control.index].up, False, "UP propagation")
l.up = True
ifdata = netns.iproute.get_if_data()[0]
self.assertEquals(ifdata[i1.control.index].up, True, "UP propagation")
self.assertEquals(ifdata[i2.control.index].up, True, "UP propagation")
#bandwidth = 100*1024*1024/8, loss=10, loss_correlation=1,delay=0.001,dup_correlation=0.1);
# FIXME: more cases
if __name__ == '__main__':
unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment