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 | |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 5 | from asfframework import VppAsfTestCase, VppTestRunner |
Gary Boon | a9ed6f7 | 2019-07-22 10:57:56 -0400 | [diff] [blame] | 6 | import os |
| 7 | |
| 8 | |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 9 | class TestMpcap(VppAsfTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 10 | """Mpcap Unit Test Cases""" |
Gary Boon | a9ed6f7 | 2019-07-22 10:57:56 -0400 | [diff] [blame] | 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): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 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 | ] |
Gary Boon | a9ed6f7 | 2019-07-22 10:57:56 -0400 | [diff] [blame] | 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) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 53 | self.assertNotIn("WrongMPCAPFileSize", "WrongMPCAPFileSize") |
Gary Boon | a9ed6f7 | 2019-07-22 10:57:56 -0400 | [diff] [blame] | 54 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 55 | |
| 56 | if __name__ == "__main__": |
Gary Boon | a9ed6f7 | 2019-07-22 10:57:56 -0400 | [diff] [blame] | 57 | unittest.main(testRunner=VppTestRunner) |