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