blob: ed8ce1e0ea924599eeddc02bff403e9e65418a46 [file] [log] [blame]
Renato Botelho do Coutoead1e532019-10-31 13:31:07 -05001#!/usr/bin/env python3
Gary Boona9ed6f72019-07-22 10:57:56 -04002
3import unittest
4
Dave Wallace8800f732023-08-31 00:47:44 -04005from asfframework import VppAsfTestCase, VppTestRunner
Gary Boona9ed6f72019-07-22 10:57:56 -04006import os
7
8
Dave Wallace8800f732023-08-31 00:47:44 -04009class TestMpcap(VppAsfTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020010 """Mpcap Unit Test Cases"""
Gary Boona9ed6f72019-07-22 10:57:56 -040011
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 Sekerad9b0c6f2022-04-26 19:02:15 +020027 """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 Boona9ed6f72019-07-22 10:57:56 -040045
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 Sekerad9b0c6f2022-04-26 19:02:15 +020053 self.assertNotIn("WrongMPCAPFileSize", "WrongMPCAPFileSize")
Gary Boona9ed6f72019-07-22 10:57:56 -040054
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020055
56if __name__ == "__main__":
Gary Boona9ed6f72019-07-22 10:57:56 -040057 unittest.main(testRunner=VppTestRunner)