summaryrefslogtreecommitdiffstats
path: root/test/test_af_packet.py
diff options
context:
space:
mode:
authorJakub Grajciar <jgrajcia@cisco.com>2019-08-26 11:25:52 +0200
committerDamjan Marion <dmarion@me.com>2019-09-12 20:25:10 +0000
commit3b2db9002c14f9e0742622f2d503c5801d443827 (patch)
tree298fabfa77400f93ae0d214c47b90da9ee912d60 /test/test_af_packet.py
parent3c7c613cf18f7825e22190be45ea7f054efafb77 (diff)
devices: af_packet API cleanup
Use consistent API types. - fix af_packet_dump dumping deleted interface Type: fix Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com> Change-Id: Ie8d138e30c8c51a2306bb2ad9ac0b7a49d5412bf Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Diffstat (limited to 'test/test_af_packet.py')
-rw-r--r--test/test_af_packet.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/test_af_packet.py b/test/test_af_packet.py
new file mode 100644
index 00000000000..9017fb71cbf
--- /dev/null
+++ b/test/test_af_packet.py
@@ -0,0 +1,39 @@
+import unittest
+import os
+import psutil
+
+from framework import VppTestCase, VppTestRunner
+from vpp_devices import VppAFPacketInterface
+
+
+class TestAFPacket(VppTestCase):
+ """ Host interface Test Case """
+
+ host_if_name = 'afp0'
+
+ @classmethod
+ def setUpClass(cls):
+ super(TestAFPacket, cls).setUpClass()
+ os.system('ip tuntap add dev ' + cls.host_if_name + ' mode tap')
+
+ @classmethod
+ def tearDownClass(cls):
+ super(TestAFPacket, cls).tearDownClass()
+ os.system('ip link delete ' + cls.host_if_name)
+
+ def test_tap_add_del(self):
+ """Create host interface"""
+ # check if host interface exists
+ self.assertTrue(
+ psutil.net_if_addrs().get(
+ self.host_if_name),
+ 'Host interface ' +
+ self.host_if_name +
+ ' does not exist')
+ afp0 = VppAFPacketInterface(self, self.host_if_name)
+ afp0.add_vpp_config()
+ self.assertTrue(afp0.query_vpp_config())
+
+
+if __name__ == '__main__':
+ unittest.main(testRunner=VppTestRunner)