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