diff --git a/test_rip.py b/test_rip.py index 17a244a..a6cd2b2 100644 --- a/test_rip.py +++ b/test_rip.py @@ -7,6 +7,7 @@ TBD: incomplete. """ +import re from topotato.v1 import * @@ -83,6 +84,12 @@ class Configs(FRRConfigs): """ +def strip_header(text): + if m := re.match(r"""^Codes:.+?\n\n""", text, re.MULTILINE | re.DOTALL): + return text[m.end():] + return text + + class RIPBasic(TestBase, AutoFixture, topo=topology, configs=Configs): @topotatofunc def test(self, topo, r1, r2, r3, rtsta): @@ -162,11 +169,6 @@ def test(self, topo, r1, r2, r3, rtsta): ) compare = r""" - Codes: R - RIP, C - connected, S - Static, O - OSPF, B - BGP - Sub-codes: - (n) - normal, (s) - static, (d) - default, (r) - redistribute, - (i) - interface - Network Next Hop Metric From Tag Time R(n) 10.103.0.0/16 193.1.1.2 3 193.1.1.2 0 $$[0-9:]+$$ R(n) 10.104.0.0/16 193.1.1.2 3 193.1.1.2 0 $$[0-9:]+$$ @@ -175,14 +177,9 @@ def test(self, topo, r1, r2, r3, rtsta): C(i) 193.1.1.0/26 0.0.0.0 1 self 0 R(n) 193.1.2.0/26 193.1.1.2 2 193.1.1.2 0 $$[0-9:]+$$ """ - yield from AssertVtysh.make(r1, "ripd", "show ip rip", compare, maxwait=10.0) + yield from AssertVtysh.make(r1, "ripd", "show ip rip", compare, maxwait=10.0, filters=[strip_header]) compare = r""" - Codes: R - RIP, C - connected, S - Static, O - OSPF, B - BGP - Sub-codes: - (n) - normal, (s) - static, (d) - default, (r) - redistribute, - (i) - interface - Network Next Hop Metric From Tag Time R(n) 10.103.0.0/16 193.1.2.3 2 193.1.2.3 0 $$[0-9:]+$$ R(n) 10.104.0.0/16 193.1.2.3 2 193.1.2.3 0 $$[0-9:]+$$ @@ -191,14 +188,9 @@ def test(self, topo, r1, r2, r3, rtsta): C(i) 193.1.1.0/26 0.0.0.0 1 self 0 C(i) 193.1.2.0/26 0.0.0.0 1 self 0 """ - yield from AssertVtysh.make(r2, "ripd", "show ip rip", compare, maxwait=10.0) + yield from AssertVtysh.make(r2, "ripd", "show ip rip", compare, maxwait=10.0, filters=[strip_header]) compare = r""" - Codes: R - RIP, C - connected, S - Static, O - OSPF, B - BGP - Sub-codes: - (n) - normal, (s) - static, (d) - default, (r) - redistribute, - (i) - interface - Network Next Hop Metric From Tag Time C(r) 10.103.0.0/16 0.0.0.0 1 self 0 S(r) 10.104.0.0/16 10.103.0.4 1 self 0 @@ -207,4 +199,4 @@ def test(self, topo, r1, r2, r3, rtsta): R(n) 193.1.1.0/26 193.1.2.2 2 193.1.2.2 0 $$[0-9:]+$$ C(i) 193.1.2.0/26 0.0.0.0 1 self 0 """ - yield from AssertVtysh.make(r3, "ripd", "show ip rip", compare, maxwait=10.0) + yield from AssertVtysh.make(r3, "ripd", "show ip rip", compare, maxwait=10.0, filters=[strip_header])