From 8a28936d410c584444acb3a284aac9b0bee68267 Mon Sep 17 00:00:00 2001 From: "G. Paul Ziemba" Date: Tue, 20 Feb 2018 00:42:16 -0800 Subject: lib: bgprib utility to compare rib against list of required routes Signed-off-by: G. Paul Ziemba --- tests/topotests/lib/bgprib.py | 105 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 tests/topotests/lib/bgprib.py (limited to 'tests/topotests/lib/bgprib.py') diff --git a/tests/topotests/lib/bgprib.py b/tests/topotests/lib/bgprib.py new file mode 100644 index 0000000000..4e069a3d58 --- /dev/null +++ b/tests/topotests/lib/bgprib.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python + +# +# want_rd_routes = [ +# {'rd':'10:1', 'p':'5.1.0.0/24', 'n':'1.1.1.1'}, +# {'rd':'10:1', 'p':'5.1.0.0/24', 'n':'1.1.1.1'}, +# +# {'rd':'10:3', 'p':'5.1.0.0/24', 'n':'3.3.3.3'}, +# ] +# +# ribRequireVpnRoutes('r2','Customer routes',want_rd_routes) +# +# want_unicast_routes = [ +# {'p':'5.1.0.0/24', 'n':'1.1.1.1'}, +# ] +# +# ribRequireUnicastRoutes('r1','ipv4','r1-cust1','Customer routes in vrf',want_unicast_routes) +# ribRequireUnicastRoutes('r1','ipv4','','Customer routes in default',want_unicast_routes) +# + +from lutil import luCommand,luResult +import json + +# gpz: get rib in json form and compare against desired routes +class Rib: + def routes_include_wanted(self,pfxtbl,want,debug): + # helper function to RequireVpnRoutes + for pfx in pfxtbl.iterkeys(): + if debug: + print 'trying pfx ' + pfx + if pfx != want['p']: + if debug: + print 'want pfx=' + want['p'] + ', not ' + pfx + continue + if debug: + print 'have pfx=' + pfx + for r in pfxtbl[pfx]: + if debug: + print 'trying route' + nexthops = r['nexthops'] + for nh in nexthops: + if debug: + print 'trying nh ' + nh['ip'] + if nh['ip'] == want['n']: + if debug: + print 'found ' + want['n'] + return 1 + else: + if debug: + print 'want nh=' + want['n'] + ', not ' + nh['ip'] + if debug: + print 'missing route: pfx=' + want['p'] + ', nh=' + want['n'] + return 0 + + def RequireVpnRoutes(self, target, title, wantroutes, debug=0): + import json + ret = luCommand(target,'vtysh -c "show bgp ipv4 vpn json"','.*','None','Get VPN RIB') + rib = json.loads(ret) + rds = rib['routes']['routeDistinguishers'] + for want in wantroutes: + found = 0 + if debug: + print "want rd " + want['rd'] + for rd in rds.iterkeys(): + if rd != want['rd']: + continue + if debug: + print "found rd " + rd + table = rds[rd] + if self.routes_include_wanted(table,want,debug): + found = 1 + break + if not found: + luResult(target, False, title) + return + luResult(target, True, title) + + def RequireUnicastRoutes(self,target,afi,vrf,title,wantroutes,debug=0): + + vrfstr = '' + if vrf != '': + vrfstr = 'vrf %s' % (vrf) + + if (afi != 'ipv4') and (afi != 'ipv6'): + print "ERROR invalid afi"; + + str = 'show bgp %s %s unicast json' % (vrfstr, afi) + cmd = 'vtysh -c "%s"' % str + ret = luCommand(target,cmd,'.*','None','Get %s %s RIB' % (vrfstr, afi)) + rib = json.loads(ret) + table = rib['routes'] + for want in wantroutes: + if not self.routes_include_wanted(table,want,debug): + luResult(target, False, title) + return + luResult(target, True, title) + + +Rib=Rib() + +def ribRequireVpnRoutes(target, title, wantroutes): + Rib.RequireVpnRoutes(target, title, wantroutes) + +def ribRequireUnicastRoutes(target, afi, vrf, title, wantroutes): + Rib.RequireUnicastRoutes(target, afi, vrf, title, wantroutes) -- cgit v1.2.3 From 044e2a31193f8a7a36c6b4c2c470836f4c7d7322 Mon Sep 17 00:00:00 2001 From: "G. Paul Ziemba" Date: Tue, 20 Feb 2018 21:31:02 -0800 Subject: lib/bgprib.py naming rib->bgprib is more accurate Signed-off-by: G. Paul Ziemba --- tests/topotests/lib/bgprib.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/topotests/lib/bgprib.py') diff --git a/tests/topotests/lib/bgprib.py b/tests/topotests/lib/bgprib.py index 4e069a3d58..39cb0e71f7 100644 --- a/tests/topotests/lib/bgprib.py +++ b/tests/topotests/lib/bgprib.py @@ -22,7 +22,7 @@ from lutil import luCommand,luResult import json # gpz: get rib in json form and compare against desired routes -class Rib: +class BgpRib: def routes_include_wanted(self,pfxtbl,want,debug): # helper function to RequireVpnRoutes for pfx in pfxtbl.iterkeys(): @@ -96,10 +96,10 @@ class Rib: luResult(target, True, title) -Rib=Rib() +BgpRib=BgpRib() -def ribRequireVpnRoutes(target, title, wantroutes): - Rib.RequireVpnRoutes(target, title, wantroutes) +def bgpribRequireVpnRoutes(target, title, wantroutes): + BgpRib.RequireVpnRoutes(target, title, wantroutes) -def ribRequireUnicastRoutes(target, afi, vrf, title, wantroutes): - Rib.RequireUnicastRoutes(target, afi, vrf, title, wantroutes) +def bgpribRequireUnicastRoutes(target, afi, vrf, title, wantroutes): + BgpRib.RequireUnicastRoutes(target, afi, vrf, title, wantroutes) -- cgit v1.2.3 From 1630ad4695876238d6d0e3c9e7f3f713777d531e Mon Sep 17 00:00:00 2001 From: "G. Paul Ziemba" Date: Thu, 22 Feb 2018 17:46:34 -0800 Subject: bgp_l3vpn_to_bgp_vrf: assign different RDs to customers on r4 Signed-off-by: G. Paul Ziemba --- tests/topotests/bgp_l3vpn_to_bgp_vrf/r4/bgpd.conf | 4 +- .../bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py | 49 +++++++++++++--------- tests/topotests/lib/bgprib.py | 8 ++-- 3 files changed, 36 insertions(+), 25 deletions(-) (limited to 'tests/topotests/lib/bgprib.py') diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/r4/bgpd.conf b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r4/bgpd.conf index aa1c2a086d..58c547647a 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/r4/bgpd.conf +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/r4/bgpd.conf @@ -31,7 +31,7 @@ router bgp 5227 vrf r4-cust1 vpn-policy ipv4 label 1041 - rd 10:4 + rd 10:41 rt both 52:100 ! nexthop 192.168.1.1 exit @@ -53,7 +53,7 @@ router bgp 5228 vrf r4-cust2 vpn-policy ipv4 label 1042 - rd 10:4 + rd 10:42 #note RT same as r4-cust1 for inter-vrf route leaking rt both 52:100 ! nexthop 192.168.1.1 diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py index d2dfb07071..d6736c3574 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py @@ -91,7 +91,18 @@ luCommand('r1','vtysh -c "show bgp ipv4 vpn"','Distinguisher: *10:1.*5.1.0.0/24 luCommand('r3','vtysh -c "show bgp ipv4 vpn"','Distinguisher: *10:3.*5.1.0.0/24 *3.3.3.3 .*5.1.1.0/24 *3.3.3.3 .*99.0.0.2/32 *3.3.3.3 ','pass','vrf->vpn routes') -luCommand('r4','vtysh -c "show bgp ipv4 vpn"','Distinguisher: *10:4.*5.1.2.0/24 *4.4.4.4 .*5.1.3.0/24 *4.4.4.4 .*5.4.2.0/24 *4.4.4.4 .*5.4.3.0/24 *4.4.4.4 .*99.0.0.3/32 *4.4.4.4 .*99.0.0.4/32 *4.4.4.4 ','pass','vrf->vpn routes') +#luCommand('r4','vtysh -c "show bgp ipv4 vpn"','Distinguisher: *10:4.*5.1.2.0/24 *4.4.4.4 .*5.1.3.0/24 *4.4.4.4 .*5.4.2.0/24 *4.4.4.4 .*5.4.3.0/24 *4.4.4.4 .*99.0.0.3/32 *4.4.4.4 .*99.0.0.4/32 *4.4.4.4 ','pass','vrf->vpn routes') + +want = [ + {'rd':'10:41', 'p':'5.1.2.0/24', 'n':'4.4.4.4'}, + {'rd':'10:41', 'p':'5.1.3.0/24', 'n':'4.4.4.4'}, + {'rd':'10:41', 'p':'99.0.0.3/32', 'n':'4.4.4.4'}, + + {'rd':'10:42', 'p':'5.4.2.0/24', 'n':'4.4.4.4'}, + {'rd':'10:42', 'p':'5.4.3.0/24', 'n':'4.4.4.4'}, + {'rd':'10:42', 'p':'99.0.0.4/32', 'n':'4.4.4.4'}, +] +bgpribRequireVpnRoutes('r4','vrf->vpn routes',want) ######################################################################## # PE routers: exporting vrfs set MPLS vrf labels in kernel @@ -114,13 +125,13 @@ want_rd_routes = [ {'rd':'10:3', 'p':'5.1.0.0/24', 'n':'3.3.3.3'}, {'rd':'10:3', 'p':'99.0.0.2/32', 'n':'3.3.3.3'}, - {'rd':'10:4', 'p':'5.1.2.0/24', 'n':'4.4.4.4'}, - {'rd':'10:4', 'p':'5.1.3.0/24', 'n':'4.4.4.4'}, - {'rd':'10:4', 'p':'99.0.0.3/32', 'n':'4.4.4.4'}, + {'rd':'10:41', 'p':'5.1.2.0/24', 'n':'4.4.4.4'}, + {'rd':'10:41', 'p':'5.1.3.0/24', 'n':'4.4.4.4'}, + {'rd':'10:41', 'p':'99.0.0.3/32', 'n':'4.4.4.4'}, - {'rd':'10:4', 'p':'5.4.2.0/24', 'n':'4.4.4.4'}, - {'rd':'10:4', 'p':'5.4.3.0/24', 'n':'4.4.4.4'}, - {'rd':'10:4', 'p':'99.0.0.3/32', 'n':'4.4.4.4'}, + {'rd':'10:42', 'p':'5.4.2.0/24', 'n':'4.4.4.4'}, + {'rd':'10:42', 'p':'5.4.3.0/24', 'n':'4.4.4.4'}, + {'rd':'10:42', 'p':'99.0.0.4/32', 'n':'4.4.4.4'}, ] bgpribRequireVpnRoutes('r2','Customer routes in provider vpn core',want_rd_routes) @@ -135,13 +146,13 @@ want_r1_remote_vpn_routes = [ {'rd':'10:3', 'p':'5.1.1.0/24', 'n':'3.3.3.3'}, {'rd':'10:3', 'p':'99.0.0.2/32', 'n':'3.3.3.3'}, - {'rd':'10:4', 'p':'5.1.2.0/24', 'n':'4.4.4.4'}, - {'rd':'10:4', 'p':'5.1.3.0/24', 'n':'4.4.4.4'}, - {'rd':'10:4', 'p':'99.0.0.3/32', 'n':'4.4.4.4'}, + {'rd':'10:41', 'p':'5.1.2.0/24', 'n':'4.4.4.4'}, + {'rd':'10:41', 'p':'5.1.3.0/24', 'n':'4.4.4.4'}, + {'rd':'10:41', 'p':'99.0.0.3/32', 'n':'4.4.4.4'}, - {'rd':'10:4', 'p':'5.4.2.0/24', 'n':'4.4.4.4'}, - {'rd':'10:4', 'p':'5.4.3.0/24', 'n':'4.4.4.4'}, - {'rd':'10:4', 'p':'99.0.0.3/32', 'n':'4.4.4.4'}, + {'rd':'10:42', 'p':'5.4.2.0/24', 'n':'4.4.4.4'}, + {'rd':'10:42', 'p':'5.4.3.0/24', 'n':'4.4.4.4'}, + {'rd':'10:42', 'p':'99.0.0.4/32', 'n':'4.4.4.4'}, ] bgpribRequireVpnRoutes('r1','Remote Customer routes in R1 vpn',want_r1_remote_vpn_routes) @@ -150,13 +161,13 @@ want_r3_remote_vpn_routes = [ {'rd':'10:1', 'p':'5.1.1.0/24', 'n':'1.1.1.1'}, {'rd':'10:1', 'p':'99.0.0.1/32', 'n':'1.1.1.1'}, - {'rd':'10:4', 'p':'5.1.2.0/24', 'n':'4.4.4.4'}, - {'rd':'10:4', 'p':'5.1.3.0/24', 'n':'4.4.4.4'}, - {'rd':'10:4', 'p':'99.0.0.3/32', 'n':'4.4.4.4'}, + {'rd':'10:41', 'p':'5.1.2.0/24', 'n':'4.4.4.4'}, + {'rd':'10:41', 'p':'5.1.3.0/24', 'n':'4.4.4.4'}, + {'rd':'10:41', 'p':'99.0.0.3/32', 'n':'4.4.4.4'}, - {'rd':'10:4', 'p':'5.4.2.0/24', 'n':'4.4.4.4'}, - {'rd':'10:4', 'p':'5.4.3.0/24', 'n':'4.4.4.4'}, - {'rd':'10:4', 'p':'99.0.0.3/32', 'n':'4.4.4.4'}, + {'rd':'10:42', 'p':'5.4.2.0/24', 'n':'4.4.4.4'}, + {'rd':'10:42', 'p':'5.4.3.0/24', 'n':'4.4.4.4'}, + {'rd':'10:42', 'p':'99.0.0.4/32', 'n':'4.4.4.4'}, ] bgpribRequireVpnRoutes('r3','Remote Customer routes in R3 vpn',want_r3_remote_vpn_routes) diff --git a/tests/topotests/lib/bgprib.py b/tests/topotests/lib/bgprib.py index 39cb0e71f7..9bd038e675 100644 --- a/tests/topotests/lib/bgprib.py +++ b/tests/topotests/lib/bgprib.py @@ -98,8 +98,8 @@ class BgpRib: BgpRib=BgpRib() -def bgpribRequireVpnRoutes(target, title, wantroutes): - BgpRib.RequireVpnRoutes(target, title, wantroutes) +def bgpribRequireVpnRoutes(target, title, wantroutes, debug=0): + BgpRib.RequireVpnRoutes(target, title, wantroutes, debug) -def bgpribRequireUnicastRoutes(target, afi, vrf, title, wantroutes): - BgpRib.RequireUnicastRoutes(target, afi, vrf, title, wantroutes) +def bgpribRequireUnicastRoutes(target, afi, vrf, title, wantroutes, debug=0): + BgpRib.RequireUnicastRoutes(target, afi, vrf, title, wantroutes, debug) -- cgit v1.2.3 From 587e28a4f05aa46715120cc8ab2b37f46993cde7 Mon Sep 17 00:00:00 2001 From: "G. Paul Ziemba" Date: Tue, 6 Mar 2018 13:11:13 -0800 Subject: lib/bgprib.py: handle empty json results gracefully Signed-off-by: G. Paul Ziemba --- tests/topotests/lib/bgprib.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/topotests/lib/bgprib.py') diff --git a/tests/topotests/lib/bgprib.py b/tests/topotests/lib/bgprib.py index 9bd038e675..b6fcd91794 100644 --- a/tests/topotests/lib/bgprib.py +++ b/tests/topotests/lib/bgprib.py @@ -20,6 +20,7 @@ from lutil import luCommand,luResult import json +import re # gpz: get rib in json form and compare against desired routes class BgpRib: @@ -55,6 +56,12 @@ class BgpRib: def RequireVpnRoutes(self, target, title, wantroutes, debug=0): import json ret = luCommand(target,'vtysh -c "show bgp ipv4 vpn json"','.*','None','Get VPN RIB') + if re.search(r'^\s*$', ret): + # degenerate case: empty json means no routes + if len(wantroutes) > 0: + luResult(target, False, title) + return + luResult(target, True, title) rib = json.loads(ret) rds = rib['routes']['routeDistinguishers'] for want in wantroutes: @@ -87,6 +94,12 @@ class BgpRib: str = 'show bgp %s %s unicast json' % (vrfstr, afi) cmd = 'vtysh -c "%s"' % str ret = luCommand(target,cmd,'.*','None','Get %s %s RIB' % (vrfstr, afi)) + if re.search(r'^\s*$', ret): + # degenerate case: empty json means no routes + if len(wantroutes) > 0: + luResult(target, False, title) + return + luResult(target, True, title) rib = json.loads(ret) table = rib['routes'] for want in wantroutes: -- cgit v1.2.3 From d521440020bdf8801e743548b43d39a495baacd4 Mon Sep 17 00:00:00 2001 From: "G. Paul Ziemba" Date: Thu, 12 Apr 2018 08:43:33 -0700 Subject: lib/bgprib.py: add copyright notice Signed-off-by: G. Paul Ziemba --- tests/topotests/lib/bgprib.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/topotests/lib/bgprib.py') diff --git a/tests/topotests/lib/bgprib.py b/tests/topotests/lib/bgprib.py index b6fcd91794..de1a1846f4 100644 --- a/tests/topotests/lib/bgprib.py +++ b/tests/topotests/lib/bgprib.py @@ -1,5 +1,21 @@ #!/usr/bin/env python +# Copyright 2018, LabN Consulting, L.L.C. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; see the file COPYING; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + # # want_rd_routes = [ # {'rd':'10:1', 'p':'5.1.0.0/24', 'n':'1.1.1.1'}, -- cgit v1.2.3 From 6c700097d66fe8b9f529a23e8d986cf2c7a0f6c7 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Sat, 2 Jun 2018 15:06:47 -0400 Subject: lib: bgprib - get human readable verson of json commands for log Signed-off-by: Lou Berger --- tests/topotests/lib/bgprib.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'tests/topotests/lib/bgprib.py') diff --git a/tests/topotests/lib/bgprib.py b/tests/topotests/lib/bgprib.py index de1a1846f4..0a00b5e5a6 100644 --- a/tests/topotests/lib/bgprib.py +++ b/tests/topotests/lib/bgprib.py @@ -71,7 +71,9 @@ class BgpRib: def RequireVpnRoutes(self, target, title, wantroutes, debug=0): import json - ret = luCommand(target,'vtysh -c "show bgp ipv4 vpn json"','.*','None','Get VPN RIB') + #non json form for humans + luCommand(target,'vtysh -c "show bgp ipv4 vpn"','.','None','Get VPN RIB (non-json)') + ret = luCommand(target,'vtysh -c "show bgp ipv4 vpn json"','.*','None','Get VPN RIB (json)') if re.search(r'^\s*$', ret): # degenerate case: empty json means no routes if len(wantroutes) > 0: @@ -107,9 +109,12 @@ class BgpRib: if (afi != 'ipv4') and (afi != 'ipv6'): print "ERROR invalid afi"; - str = 'show bgp %s %s unicast json' % (vrfstr, afi) + str = 'show bgp %s %s unicast' % (vrfstr, afi) + #non json form for humans cmd = 'vtysh -c "%s"' % str - ret = luCommand(target,cmd,'.*','None','Get %s %s RIB' % (vrfstr, afi)) + luCommand(target,cmd,'.','None','Get %s %s RIB (non-json)' % (vrfstr, afi)) + cmd = 'vtysh -c "%s json"' % str + ret = luCommand(target,cmd,'.*','None','Get %s %s RIB (json)' % (vrfstr, afi)) if re.search(r'^\s*$', ret): # degenerate case: empty json means no routes if len(wantroutes) > 0: -- cgit v1.2.3 From ffd3f544938eefd13c84ac4743c3afe1442d0aa7 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Wed, 11 Jul 2018 11:17:48 -0400 Subject: lib: more logging to aid in failure debugging Signed-off-by: Lou Berger --- tests/topotests/lib/bgprib.py | 25 +++++++++++++------------ tests/topotests/lib/lutil.py | 10 +++++++--- 2 files changed, 20 insertions(+), 15 deletions(-) (limited to 'tests/topotests/lib/bgprib.py') diff --git a/tests/topotests/lib/bgprib.py b/tests/topotests/lib/bgprib.py index 0a00b5e5a6..8ec1511e10 100644 --- a/tests/topotests/lib/bgprib.py +++ b/tests/topotests/lib/bgprib.py @@ -71,15 +71,16 @@ class BgpRib: def RequireVpnRoutes(self, target, title, wantroutes, debug=0): import json + logstr = "RequireVpnRoutes " + str(wantroutes) #non json form for humans luCommand(target,'vtysh -c "show bgp ipv4 vpn"','.','None','Get VPN RIB (non-json)') ret = luCommand(target,'vtysh -c "show bgp ipv4 vpn json"','.*','None','Get VPN RIB (json)') if re.search(r'^\s*$', ret): # degenerate case: empty json means no routes if len(wantroutes) > 0: - luResult(target, False, title) + luResult(target, False, title, logstr) return - luResult(target, True, title) + luResult(target, True, title, logstr) rib = json.loads(ret) rds = rib['routes']['routeDistinguishers'] for want in wantroutes: @@ -96,12 +97,12 @@ class BgpRib: found = 1 break if not found: - luResult(target, False, title) + luResult(target, False, title, logstr) return - luResult(target, True, title) + luResult(target, True, title, logstr) def RequireUnicastRoutes(self,target,afi,vrf,title,wantroutes,debug=0): - + logstr = "RequireVpnRoutes " + str(wantroutes) vrfstr = '' if vrf != '': vrfstr = 'vrf %s' % (vrf) @@ -109,25 +110,25 @@ class BgpRib: if (afi != 'ipv4') and (afi != 'ipv6'): print "ERROR invalid afi"; - str = 'show bgp %s %s unicast' % (vrfstr, afi) + cmdstr = 'show bgp %s %s unicast' % (vrfstr, afi) #non json form for humans - cmd = 'vtysh -c "%s"' % str + cmd = 'vtysh -c "%s"' % cmdstr luCommand(target,cmd,'.','None','Get %s %s RIB (non-json)' % (vrfstr, afi)) - cmd = 'vtysh -c "%s json"' % str + cmd = 'vtysh -c "%s json"' % cmdstr ret = luCommand(target,cmd,'.*','None','Get %s %s RIB (json)' % (vrfstr, afi)) if re.search(r'^\s*$', ret): # degenerate case: empty json means no routes if len(wantroutes) > 0: - luResult(target, False, title) + luResult(target, False, title, logstr) return - luResult(target, True, title) + luResult(target, True, title, logstr) rib = json.loads(ret) table = rib['routes'] for want in wantroutes: if not self.routes_include_wanted(table,want,debug): - luResult(target, False, title) + luResult(target, False, title, logstr) return - luResult(target, True, title) + luResult(target, True, title, logstr) BgpRib=BgpRib() diff --git a/tests/topotests/lib/lutil.py b/tests/topotests/lib/lutil.py index 9be6505eeb..3ae18018bf 100755 --- a/tests/topotests/lib/lutil.py +++ b/tests/topotests/lib/lutil.py @@ -72,16 +72,20 @@ Test Target Summary Pass Fail\n ******************************************************************************\n') self.fsum.write(str+'\n') - def result(self, target, success, str): + def result(self, target, success, str, logstr=None): if success: p = 1 f = 0 self.l_pass += 1 + sstr = "PASS" else: f = 1 p = 0 self.l_fail += 1 + sstr = "FAIL" self.l_total += 1 + if logstr != None: + self.log("R:%d %s: %s" % (self.l_total, sstr, logstr)) res = "%-4d %-6s %-56s %-4d %d" % (self.l_total, target, str, p, f) self.log ('R:'+res) self.summary(res) @@ -320,8 +324,8 @@ def luNumFail(): def luNumPass(): return LUtil.l_pass -def luResult(target, success, str): - return LUtil.result(target, success, str) +def luResult(target, success, str, logstr=None): + return LUtil.result(target, success, str, logstr) def luShowFail(): printed = 0 -- cgit v1.2.3