]> git.proxmox.com Git - mirror_frr.git/blob - tests/bgpd/test_aspath.py
Merge pull request #12700 from taspelund/martian_tip_improvement
[mirror_frr.git] / tests / bgpd / test_aspath.py
1 import frrtest
2 import re
3
4 re_okfail = re.compile(
5 r"^(?:\x1b\[3[12]m)?(?P<ret>OK|failed)".encode("utf8"), re.MULTILINE
6 )
7
8
9 class TestAspath(frrtest.TestMultiOut):
10 program = "./test_aspath"
11
12 def _parsertest(self, line):
13 if not hasattr(self, "parserno"):
14 self.parserno = -1
15 self.parserno += 1
16
17 self._onesimple("test %d" % self.parserno)
18 self._okfail("%s:" % line, okfail=re_okfail)
19 self._okfail("empty prepend %s:" % line, okfail=re_okfail)
20
21 def _attrtest(self, line):
22 if not hasattr(self, "attrno"):
23 self.attrno = -1
24 self.attrno += 1
25
26 self._onesimple("aspath_attr test %d" % self.attrno)
27 self._okfail(line, okfail=re_okfail)
28
29
30 TestAspath.parsertest("seq1")
31 TestAspath.parsertest("seq2")
32 TestAspath.parsertest("seq3")
33 TestAspath.parsertest("seqset")
34 TestAspath.parsertest("seqset2")
35 TestAspath.parsertest("multi")
36 TestAspath.parsertest("confed")
37 TestAspath.parsertest("confed2")
38 TestAspath.parsertest("confset")
39 TestAspath.parsertest("confmulti")
40 TestAspath.parsertest("seq4")
41 TestAspath.parsertest("tripleseq1")
42 TestAspath.parsertest("someprivate")
43 TestAspath.parsertest("allprivate")
44 TestAspath.parsertest("long")
45 TestAspath.parsertest("seq1extra")
46 TestAspath.parsertest("empty")
47 TestAspath.parsertest("redundantset")
48 TestAspath.parsertest("reconcile_lead_asp")
49 TestAspath.parsertest("reconcile_new_asp")
50 TestAspath.parsertest("reconcile_confed")
51 TestAspath.parsertest("reconcile_start_trans")
52 TestAspath.parsertest("reconcile_start_trans4")
53 TestAspath.parsertest("reconcile_start_trans_error")
54 TestAspath.parsertest("redundantset2")
55 TestAspath.parsertest("zero-size overflow")
56 TestAspath.parsertest("zero-size overflow + valid segment")
57 TestAspath.parsertest("invalid segment type")
58 TestAspath.parsertest("BGP_AS_ZERO")
59
60 for i in range(10):
61 TestAspath.okfail("prepend test %d" % i)
62 for i in range(5):
63 TestAspath.okfail("aggregate test %d" % i)
64 for i in range(5):
65 TestAspath.okfail("reconcile test %d" % i)
66 for _ in range(22):
67 TestAspath.okfail("left cmp ")
68
69 TestAspath.okfail("empty_get_test")
70
71 TestAspath.attrtest("basic test")
72 TestAspath.attrtest("length too short")
73 TestAspath.attrtest("length too long")
74 TestAspath.attrtest("incorrect flag")
75 TestAspath.attrtest("as4_path, with as2 format data")
76 TestAspath.attrtest("as4, with incorrect attr length")
77 TestAspath.attrtest("basic 4-byte as-path")
78 TestAspath.attrtest("4b AS_PATH: too short")
79 TestAspath.attrtest("4b AS_PATH: too long")
80 TestAspath.attrtest("4b AS_PATH: too long2")
81 TestAspath.attrtest("4b AS_PATH: bad flags")
82 TestAspath.attrtest("4b AS4_PATH w/o AS_PATH")
83 TestAspath.attrtest("4b AS4_PATH: confed")
84 TestAspath.attrtest("4b AS4_PATH: BGP_AS_ZERO")