Renato Botelho do Couto | ead1e53 | 2019-10-31 13:31:07 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Gary Boon | a9ed6f7 | 2019-07-22 10:57:56 -0400 | [diff] [blame] | 2 | |
| 3 | import unittest |
| 4 | |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 5 | from framework import VppTestCase, VppTestRunner |
Gary Boon | a9ed6f7 | 2019-07-22 10:57:56 -0400 | [diff] [blame] | 6 | from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath |
| 7 | import os |
| 8 | |
| 9 | |
| 10 | class TestMpcap(VppTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 11 | """Mpcap Unit Test Cases""" |
Gary Boon | a9ed6f7 | 2019-07-22 10:57:56 -0400 | [diff] [blame] | 12 | |
| 13 | @classmethod |
| 14 | def setUpClass(cls): |
| 15 | super(TestMpcap, cls).setUpClass() |
| 16 | |
| 17 | @classmethod |
| 18 | def tearDownClass(cls): |
| 19 | super(TestMpcap, cls).tearDownClass() |
| 20 | |
| 21 | def setUp(self): |
| 22 | super(TestMpcap, self).setUp() |
| 23 | |
| 24 | def tearDown(self): |
| 25 | super(TestMpcap, self).tearDown() |
| 26 | |
| 27 | def test_mpcap_unittest(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 28 | """Mapped pcap file test""" |
| 29 | cmds = [ |
| 30 | "packet-generator new {\n" |
| 31 | " name mpcap\n" |
| 32 | " limit 15\n" |
| 33 | " size 128-128\n" |
| 34 | " interface local0\n" |
| 35 | " node mpcap-unittest\n" |
| 36 | " data {\n" |
| 37 | " IP6: 00:d0:2d:5e:86:85 -> 00:0d:ea:d0:00:00\n" |
| 38 | " ICMP: db00::1 -> db00::2\n" |
| 39 | " incrementing 30\n" |
| 40 | " }\n", |
| 41 | "trace add pg-input 15", |
| 42 | "pa en", |
| 43 | "show trace", |
| 44 | "show error", |
| 45 | ] |
Gary Boon | a9ed6f7 | 2019-07-22 10:57:56 -0400 | [diff] [blame] | 46 | |
| 47 | for cmd in cmds: |
| 48 | self.logger.info(self.vapi.cli(cmd)) |
| 49 | |
| 50 | size = os.path.getsize("/tmp/mpcap_unittest.pcap") |
| 51 | os.remove("/tmp/mpcap_unittest.pcap") |
| 52 | if size != 2184: |
| 53 | self.logger.critical("BUG: file size %d not 2184" % size) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 54 | self.assertNotIn("WrongMPCAPFileSize", "WrongMPCAPFileSize") |
Gary Boon | a9ed6f7 | 2019-07-22 10:57:56 -0400 | [diff] [blame] | 55 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 56 | |
| 57 | if __name__ == "__main__": |
Gary Boon | a9ed6f7 | 2019-07-22 10:57:56 -0400 | [diff] [blame] | 58 | unittest.main(testRunner=VppTestRunner) |