summaryrefslogtreecommitdiffstats
path: root/test/test_mactime.py
blob: 85ded33d1586117baf2383906b3be0b6cf07988d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Number */
.highlight .s { color: #e6db74 } /* Literal.String */
.highlight .na { color: #a6e22e } /* Name.Attribute */
.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
.highlight .nc { color: #a6e22e } /* Name.Class */
.highlight .no { color: #66d9ef } /* Name.Constant */
.highlight .nd { color: #a6e22e } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #a6e22e } /* Name.Exception */
.highlight .nf { color: #a6e22e } /* Name.Function */
.highlight .nl { color: #f8f8f2 } /* Name.Label */
.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
.highlight .nx { color: #a6e22e } /* Name.Other */
.highlight .py { color: #f8f8f2 } /* Name.Property */
.highlight .nt { color: #f92672 } /* Name.Tag */
.
#!/usr/bin/env python3

import unittest

from framework import VppTestCase, VppTestRunner, running_gcov_tests
from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath


class TestMactime(VppTestCase):
    """ Mactime Unit Test Cases """

    @classmethod
    def setUpClass(cls):
        super(TestMactime, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(TestMactime, cls).tearDownClass()

    def setUp(self):
        super(TestMactime, self).setUp()

    def tearDown(self):
        super(TestMactime, self).tearDown()

    def test_mactime_range_unittest(self):
        """ Time Range Test """
        error = self.vapi.cli("test time-range")

        if error:
            self.logger.critical(error)
        self.assertNotIn('FAILED', error)

    @unittest.skipUnless(running_gcov_tests, "part of code coverage tests")
    def test_mactime_unittest(self):
        """ Mactime Plugin Code Coverage Test """
        cmds = ["loopback create",
                "mactime enable-disable disable",
                "mactime enable-disable loop0",
                "mactime enable-disable loop0 disable",
                "mactime enable-disable sw_if_index 9999",
                "bin mactime_enable_disable loop0",
                "bin mactime_enable_disable loop0 disable",
                "bin mactime_enable_disable sw_if_index 1",
                "set interface state loop0 up",
                "clear mactime",
                "set ip neighbor loop0 192.168.1.1 00:d0:2d:5e:86:85",
                "bin mactime_add_del_range name sallow "
                "mac 00:d0:2d:5e:86:85 allow-static del",
                "bin mactime_add_del_range name sallow "
                "mac 00:d0:2d:5e:86:85 allow-static",
                "bin mactime_add_del_range name sallow "
                "mac 00:d0:2d:5e:86:85 allow-static del",
                "bin mactime_add_del_range name sallow "
                "mac 00:d0:2d:5e:86:85 allow-static",
                "bin mactime_add_del_range name sblock "
                "mac 01:00:5e:7f:ff:fa drop-static",
                "bin mactime_add_del_range name ddrop "
                "mac c8:bc:c8:5a:ba:f3 drop-range Sun - Sat "
                "00:00 - 23:59",
                "bin mactime_add_del_range name dallow "
                "mac c8:bc:c8:5a:ba:f4 allow-range Sun - Sat "
                "00:00 - 23:59",
                "bin mactime_add_del_range name multi "
                "mac c8:bc:c8:f0:f0:f0 allow-range Sun - Mon "
                "00:00 - 23:59 Tue - Sat 00:00 - 23:59",
                "bin mactime_add_del_range bogus",
                "bin mactime_add_del_range mac 01:00:5e:7f:f0:f0 allow-static",
                "bin mactime_add_del_range "
                "name tooloooooooooooooooooooooooooooooooooooooooooooooooo"
                "nnnnnnnnnnnnnnnnnnnnnnnnnnnng mac 00:00:de:ad:be:ef "
                "allow-static",
                "packet-generator new {\n"
                " name allow\n"
                " limit 15\n"
                " size 128-128\n"
                " interface loop0\n"
                " node ethernet-input\n"
                " data {\n"
                "   IP6: 00:d0:2d:5e:86:85 -> 00:0d:ea:d0:00:00\n"
                "   ICMP: db00::1 -> db00::2\n"
                "   incrementing 30\n"
                "   }\n",
                "}\n",
                "packet-generator new {\n"
                " name deny\n"
                " limit 15\n"
                " size 128-128\n"
                " interface loop0\n"
                " node ethernet-input\n"
                " data {\n"
                "   IP6: 01:00:5e:7f:ff:fa -> 00:0d:ea:d0:00:00\n"
                "   ICMP: db00::1 -> db00::2\n"
                "   incrementing 30\n"
                "   }\n",
                "}\n",
                "packet-generator new {\n"
                " name ddrop\n"
                " limit 15\n"
                " size 128-128\n"
                " interface loop0\n"
                " node ethernet-input\n"
                " data {\n"
                "   IP6: c8:bc:c8:5a:ba:f3 -> 00:0d:ea:d0:00:00\n"
                "   ICMP: db00::1 -> db00::2\n"
                "   incrementing 30\n"
                "   }\n",
                "}\n",
                "packet-generator new {\n"
                " name dallow\n"
                " limit 15\n"
                " size 128-128\n"
                " interface loop0\n"
                " node ethernet-input\n"
                " data {\n"
                "   IP6: c8:bc:c8:5a:ba:f4 -> 00:0d:ea:d0:00:00\n"
                "   ICMP: db00::1 -> db00::2\n"
                "   incrementing 30\n"
                "   }\n"
                "}\n"
                "packet-generator new {\n"
                " name makeentry\n"
                " limit 15\n"
                " size 128-128\n"
                " interface loop0\n"
                " node ethernet-input\n"
                " data {\n"
                "   IP6: c8:bc:c8:5a:b0:0b -> 00:0d:ea:d0:00:00\n"
                "   ICMP: db00::1 -> db00::2\n"
                "   incrementing 30\n"
                "   }\n"
                "}\n"
                "packet-generator new {\n"
                " name tx\n"
                " limit 15\n"
                " size 128-128\n"
                " interface local0\n"
                " tx-interface loop0\n"
                " node loop0-output\n"
                " data {\n"
                "   hex 0x01005e7ffffa000dead000000800"
                "0102030405060708090a0b0c0d0e0f0102030405\n"
                "   }\n"
                "}\n"
                "trace add pg-input 2",
                "pa en",
                "show mactime verbose 2",
                "show trace",
                "show error"]

        for cmd in cmds:
            r = self.vapi.cli_return_response(cmd)
            if r.retval != 0:
                if hasattr(r, 'reply'):
                    self.logger.info(cmd + " FAIL reply " + r.reply)
                else:
                    self.logger.info(cmd + " FAIL retval " + str(r.retval))

if __name__ == '__main__':
    unittest.main(testRunner=VppTestRunner)