blob: bfa4385ed1a89e8ba75dde862b5c967a61b97b1d [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
Klement Sekerab23ffd72021-05-31 16:08:53 +02005from framework import VppTestCase, VppTestRunner
Gary Boona9ed6f72019-07-22 10:57:56 -04006from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
7import os
8
9
10class TestMpcap(VppTestCase):
11 """ Mpcap Unit Test Cases """
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):
28 """ Mapped pcap file test """
29 cmds = ["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 for cmd in cmds:
46 self.logger.info(self.vapi.cli(cmd))
47
48 size = os.path.getsize("/tmp/mpcap_unittest.pcap")
49 os.remove("/tmp/mpcap_unittest.pcap")
50 if size != 2184:
51 self.logger.critical("BUG: file size %d not 2184" % size)
52 self.assertNotIn('WrongMPCAPFileSize', 'WrongMPCAPFileSize')
53
54if __name__ == '__main__':
55 unittest.main(testRunner=VppTestRunner)