5 from config import config
6 from framework import VppTestCase, VppTestRunner
7 from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath
10 class TestMactime(VppTestCase):
11 """ Mactime Unit Test Cases """
15 super(TestMactime, cls).setUpClass()
18 def tearDownClass(cls):
19 super(TestMactime, cls).tearDownClass()
22 super(TestMactime, self).setUp()
25 super(TestMactime, self).tearDown()
27 def test_mactime_range_unittest(self):
28 """ Time Range Test """
29 error = self.vapi.cli("test time-range")
32 self.logger.critical(error)
33 self.assertNotIn('FAILED', error)
35 @unittest.skipUnless(config.gcov, "part of code coverage tests")
36 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",
48 "set ip neighbor loop0 192.168.1.1 00:d0:2d:5e:86:85",
49 "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 "
62 "bin mactime_add_del_range name dallow "
63 "mac c8:bc:c8:5a:ba:f4 allow-range Sun - Sat "
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 "
74 "packet-generator new {\n"
79 " node ethernet-input\n"
81 " IP6: 00:d0:2d:5e:86:85 -> 00:0d:ea:d0:00:00\n"
82 " ICMP: db00::1 -> db00::2\n"
86 "packet-generator new {\n"
91 " node ethernet-input\n"
93 " IP6: 01:00:5e:7f:ff:fa -> 00:0d:ea:d0:00:00\n"
94 " ICMP: db00::1 -> db00::2\n"
98 "packet-generator new {\n"
103 " node ethernet-input\n"
105 " IP6: c8:bc:c8:5a:ba:f3 -> 00:0d:ea:d0:00:00\n"
106 " ICMP: db00::1 -> db00::2\n"
110 "packet-generator new {\n"
115 " node ethernet-input\n"
117 " IP6: c8:bc:c8:5a:ba:f4 -> 00:0d:ea:d0:00:00\n"
118 " ICMP: db00::1 -> db00::2\n"
122 "packet-generator new {\n"
127 " node ethernet-input\n"
129 " IP6: c8:bc:c8:5a:b0:0b -> 00:0d:ea:d0:00:00\n"
130 " ICMP: db00::1 -> db00::2\n"
134 "packet-generator new {\n"
138 " interface local0\n"
139 " tx-interface loop0\n"
140 " node loop0-output\n"
142 " hex 0x01005e7ffffa000dead000000800"
143 "0102030405060708090a0b0c0d0e0f0102030405\n"
146 "trace add pg-input 2",
148 "show mactime verbose 2",
153 r = self.vapi.cli_return_response(cmd)
155 if hasattr(r, 'reply'):
156 self.logger.info(cmd + " FAIL reply " + r.reply)
158 self.logger.info(cmd + " FAIL retval " + str(r.retval))
160 if __name__ == '__main__':
161 unittest.main(testRunner=VppTestRunner)