Commit 77515eb3 authored by Martín Ferrari's avatar Martín Ferrari

ping test!!

parent d8484300
#!/usr/bin/env python
# vim:ts=4:sw=4:et:ai:sts=4
import grp, pwd, unittest
import netns
import grp, os, pwd, unittest
import netns, test_util
class TestConfigure(unittest.TestCase):
def test_config_run_as_static(self):
......@@ -17,5 +17,21 @@ class TestConfigure(unittest.TestCase):
self.assertRaises(AttributeError, setattr, netns.config,
'run_as', -1)
class TestGlobal(unittest.TestCase):
@test_util.skipUnless(os.getuid() == 0, "Test requires root privileges")
def test_run_ping(self):
n1 = netns.Node()
n2 = netns.Node()
i1, i2 = netns.P2PInterface.create_pair(n1, n2)
i1.up = i2.up = True
i1.add_v4_address('10.0.0.1', 24)
i2.add_v4_address('10.0.0.2', 24)
null = file('/dev/null', 'wb')
a1 = n1.Popen(['ping', '-qc1', '10.0.0.2'], stdout = null)
a2 = n2.Popen(['ping', '-qc1', '10.0.0.1'], stdout = null)
self.assertEquals(a1.wait(), 0)
self.assertEquals(a2.wait(), 0)
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