tests: Add platform handling for FreeBSD
[vpp.git] / test / asf / test_mpcap.py
1 #!/usr/bin/env python3
2
3 import unittest
4
5 from asfframework import VppAsfTestCase, VppTestRunner
6 import os
7
8
9 class TestMpcap(VppAsfTestCase):
10     """Mpcap Unit Test Cases"""
11
12     @classmethod
13     def setUpClass(cls):
14         super(TestMpcap, cls).setUpClass()
15
16     @classmethod
17     def tearDownClass(cls):
18         super(TestMpcap, cls).tearDownClass()
19
20     def setUp(self):
21         super(TestMpcap, self).setUp()
22
23     def tearDown(self):
24         super(TestMpcap, self).tearDown()
25
26     def test_mpcap_unittest(self):
27         """Mapped pcap file test"""
28         cmds = [
29             "packet-generator new {\n"
30             " name mpcap\n"
31             " limit 15\n"
32             " size 128-128\n"
33             " interface local0\n"
34             " node mpcap-unittest\n"
35             " data {\n"
36             "   IP6: 00:d0:2d:5e:86:85 -> 00:0d:ea:d0:00:00\n"
37             "   ICMP: db00::1 -> db00::2\n"
38             "   incrementing 30\n"
39             "   }\n",
40             "trace add pg-input 15",
41             "pa en",
42             "show trace",
43             "show error",
44         ]
45
46         for cmd in cmds:
47             self.logger.info(self.vapi.cli(cmd))
48
49         size = os.path.getsize("/tmp/mpcap_unittest.pcap")
50         os.remove("/tmp/mpcap_unittest.pcap")
51         if size != 2184:
52             self.logger.critical("BUG: file size %d not 2184" % size)
53             self.assertNotIn("WrongMPCAPFileSize", "WrongMPCAPFileSize")
54
55
56 if __name__ == "__main__":
57     unittest.main(testRunner=VppTestRunner)