summaryrefslogtreecommitdiff
path: root/tests/topotests/lib/topotest.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/topotests/lib/topotest.py')
-rw-r--r--tests/topotests/lib/topotest.py48
1 files changed, 43 insertions, 5 deletions
diff --git a/tests/topotests/lib/topotest.py b/tests/topotests/lib/topotest.py
index 1e6ef1b2b3..70b2cfd648 100644
--- a/tests/topotests/lib/topotest.py
+++ b/tests/topotests/lib/topotest.py
@@ -516,6 +516,44 @@ def normalize_text(text):
return text
+def is_linux():
+ """
+ Parses unix name output to check if running on GNU/Linux.
+
+ Returns True if running on Linux, returns False otherwise.
+ """
+
+ if os.uname()[0] == "Linux":
+ return True
+ return False
+
+
+def iproute2_is_vrf_capable():
+ """
+ Checks if the iproute2 version installed on the system is capable of
+ handling VRFs by interpreting the output of the 'ip' utility found in PATH.
+
+ Returns True if capability can be detected, returns False otherwise.
+ """
+
+ if is_linux():
+ try:
+ subp = subprocess.Popen(
+ ["ip", "route", "show", "vrf"],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ stdin=subprocess.PIPE,
+ encoding="utf-8"
+ )
+ iproute2_err = subp.communicate()[1].splitlines()[0].split()[0]
+
+ if iproute2_err != "Error:":
+ return True
+ except Exception:
+ pass
+ return False
+
+
def module_present_linux(module, load):
"""
Returns whether `module` is present.
@@ -1424,7 +1462,7 @@ class Router(Node):
zebra_option = self.daemons_options["zebra"]
self.cmd(
"ASAN_OPTIONS=log_path=zebra.asan {0} {1} --log file:zebra.log --log-level debug -s 90000000 -d > zebra.out 2> zebra.err".format(
- zebra_path, zebra_option, self.logdir, self.name
+ zebra_path, zebra_option
)
)
logger.debug("{}: {} zebra started".format(self, self.routertype))
@@ -1439,7 +1477,7 @@ class Router(Node):
staticd_option = self.daemons_options["staticd"]
self.cmd(
"ASAN_OPTIONS=log_path=staticd.asan {0} {1} --log file:staticd.log --log-level debug -d > staticd.out 2> staticd.err".format(
- staticd_path, staticd_option, self.logdir, self.name
+ staticd_path, staticd_option
)
)
logger.debug("{}: {} staticd started".format(self, self.routertype))
@@ -1723,7 +1761,7 @@ class Router(Node):
interface = ""
ll_per_if_count = 0
for line in ifaces:
- m = re.search("[0-9]+: ([^:@]+)[@if0-9:]+ <", line)
+ m = re.search("[0-9]+: ([^:@]+)[-@a-z0-9:]+ <", line)
if m:
interface = m.group(1)
ll_per_if_count = 0
@@ -1831,8 +1869,8 @@ class LinuxRouter(Router):
class FreeBSDRouter(Router):
"A FreeBSD Router Node with IPv4/IPv6 forwarding enabled."
- def __init__(eslf, name, **params):
- Router.__init__(Self, name, **params)
+ def __init__(self, name, **params):
+ Router.__init__(self, name, **params)
class LegacySwitch(OVSSwitch):