blob: 1eaeeb53a9d88365da71e32d6f75a7ed71dc7f47 [file] [log] [blame]
Renato Botelho do Coutoead1e532019-10-31 13:31:07 -05001#!/usr/bin/env python3
Dave Barach7d31ab22019-05-08 19:18:18 -04002
3import unittest
4
Klement Sekerab23ffd72021-05-31 16:08:53 +02005from config import config
6from framework import VppTestCase, VppTestRunner
Dave Barach7d31ab22019-05-08 19:18:18 -04007from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
8
9
10class TestMactime(VppTestCase):
11 """ Mactime Unit Test Cases """
12
13 @classmethod
14 def setUpClass(cls):
15 super(TestMactime, cls).setUpClass()
16
17 @classmethod
18 def tearDownClass(cls):
19 super(TestMactime, cls).tearDownClass()
20
21 def setUp(self):
22 super(TestMactime, self).setUp()
23
24 def tearDown(self):
25 super(TestMactime, self).tearDown()
26
27 def test_mactime_range_unittest(self):
28 """ Time Range Test """
29 error = self.vapi.cli("test time-range")
30
31 if error:
32 self.logger.critical(error)
33 self.assertNotIn('FAILED', error)
34
Klement Sekerab23ffd72021-05-31 16:08:53 +020035 @unittest.skipUnless(config.gcov, "part of code coverage tests")
Dave Barach7d31ab22019-05-08 19:18:18 -040036 def test_mactime_unittest(self):
37 """ Mactime Plugin Code Coverage Test """
38 cmds = ["loopback create",
39 "mactime enable-disable disable",
40 "mactime enable-disable loop0",
41 "mactime enable-disable loop0 disable",
42 "mactime enable-disable sw_if_index 9999",
43 "bin mactime_enable_disable loop0",
44 "bin mactime_enable_disable loop0 disable",
45 "bin mactime_enable_disable sw_if_index 1",
46 "set interface state loop0 up",
47 "clear mactime",
Neale Rannscbe25aa2019-09-30 10:53:31 +000048 "set ip neighbor loop0 192.168.1.1 00:d0:2d:5e:86:85",
Dave Barach7d31ab22019-05-08 19:18:18 -040049 "bin mactime_add_del_range name sallow "
50 "mac 00:d0:2d:5e:86:85 allow-static del",
51 "bin mactime_add_del_range name sallow "
52 "mac 00:d0:2d:5e:86:85 allow-static",
53 "bin mactime_add_del_range name sallow "
54 "mac 00:d0:2d:5e:86:85 allow-static del",
55 "bin mactime_add_del_range name sallow "
56 "mac 00:d0:2d:5e:86:85 allow-static",
57 "bin mactime_add_del_range name sblock "
58 "mac 01:00:5e:7f:ff:fa drop-static",
59 "bin mactime_add_del_range name ddrop "
60 "mac c8:bc:c8:5a:ba:f3 drop-range Sun - Sat "
61 "00:00 - 23:59",
62 "bin mactime_add_del_range name dallow "
63 "mac c8:bc:c8:5a:ba:f4 allow-range Sun - Sat "
64 "00:00 - 23:59",
65 "bin mactime_add_del_range name multi "
66 "mac c8:bc:c8:f0:f0:f0 allow-range Sun - Mon "
67 "00:00 - 23:59 Tue - Sat 00:00 - 23:59",
68 "bin mactime_add_del_range bogus",
69 "bin mactime_add_del_range mac 01:00:5e:7f:f0:f0 allow-static",
70 "bin mactime_add_del_range "
71 "name tooloooooooooooooooooooooooooooooooooooooooooooooooo"
72 "nnnnnnnnnnnnnnnnnnnnnnnnnnnng mac 00:00:de:ad:be:ef "
73 "allow-static",
74 "packet-generator new {\n"
75 " name allow\n"
76 " limit 15\n"
77 " size 128-128\n"
78 " interface loop0\n"
79 " node ethernet-input\n"
80 " data {\n"
81 " IP6: 00:d0:2d:5e:86:85 -> 00:0d:ea:d0:00:00\n"
82 " ICMP: db00::1 -> db00::2\n"
83 " incrementing 30\n"
84 " }\n",
85 "}\n",
86 "packet-generator new {\n"
87 " name deny\n"
88 " limit 15\n"
89 " size 128-128\n"
90 " interface loop0\n"
91 " node ethernet-input\n"
92 " data {\n"
93 " IP6: 01:00:5e:7f:ff:fa -> 00:0d:ea:d0:00:00\n"
94 " ICMP: db00::1 -> db00::2\n"
95 " incrementing 30\n"
96 " }\n",
97 "}\n",
98 "packet-generator new {\n"
99 " name ddrop\n"
100 " limit 15\n"
101 " size 128-128\n"
102 " interface loop0\n"
103 " node ethernet-input\n"
104 " data {\n"
105 " IP6: c8:bc:c8:5a:ba:f3 -> 00:0d:ea:d0:00:00\n"
106 " ICMP: db00::1 -> db00::2\n"
107 " incrementing 30\n"
108 " }\n",
109 "}\n",
110 "packet-generator new {\n"
111 " name dallow\n"
112 " limit 15\n"
113 " size 128-128\n"
114 " interface loop0\n"
115 " node ethernet-input\n"
116 " data {\n"
117 " IP6: c8:bc:c8:5a:ba:f4 -> 00:0d:ea:d0:00:00\n"
118 " ICMP: db00::1 -> db00::2\n"
119 " incrementing 30\n"
120 " }\n"
121 "}\n"
122 "packet-generator new {\n"
123 " name makeentry\n"
124 " limit 15\n"
125 " size 128-128\n"
126 " interface loop0\n"
127 " node ethernet-input\n"
128 " data {\n"
129 " IP6: c8:bc:c8:5a:b0:0b -> 00:0d:ea:d0:00:00\n"
130 " ICMP: db00::1 -> db00::2\n"
131 " incrementing 30\n"
132 " }\n"
133 "}\n"
134 "packet-generator new {\n"
135 " name tx\n"
136 " limit 15\n"
137 " size 128-128\n"
138 " interface local0\n"
139 " tx-interface loop0\n"
140 " node loop0-output\n"
141 " data {\n"
142 " hex 0x01005e7ffffa000dead000000800"
143 "0102030405060708090a0b0c0d0e0f0102030405\n"
144 " }\n"
145 "}\n"
146 "trace add pg-input 2",
147 "pa en",
148 "show mactime verbose 2",
149 "show trace",
150 "show error"]
151
152 for cmd in cmds:
Dave Barach5932ce12019-10-09 17:28:04 -0400153 r = self.vapi.cli_return_response(cmd)
154 if r.retval != 0:
155 if hasattr(r, 'reply'):
156 self.logger.info(cmd + " FAIL reply " + r.reply)
157 else:
158 self.logger.info(cmd + " FAIL retval " + str(r.retval))
Dave Barach7d31ab22019-05-08 19:18:18 -0400159
160if __name__ == '__main__':
161 unittest.main(testRunner=VppTestRunner)